qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 4/5] Reorder POSIX compat AIO code


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH 4/5] Reorder POSIX compat AIO code
Date: Wed, 4 Apr 2012 17:08:14 +0200

Effectively no functional changes. This just moves
posix_aio_notify_event up without modifying it and folds die/die2 into
their only remaining user.

Signed-off-by: Jan Kiszka <address@hidden>
---
 posix-aio-compat.c |   44 ++++++++++++++++----------------------------
 1 files changed, 16 insertions(+), 28 deletions(-)

diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index 7c3ff6e..f093156 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -71,6 +71,7 @@ static int new_threads = 0;     /* backlog of threads we need 
to create */
 static int pending_threads = 0; /* threads created but not running yet */
 static QEMUBH *new_thread_bh;
 static QTAILQ_HEAD(, qemu_paiocb) request_list;
+static PosixAioState *posix_aio_state;
 
 #ifdef CONFIG_PREADV
 static int preadv_present = 1;
@@ -78,17 +79,6 @@ static int preadv_present = 1;
 static int preadv_present = 0;
 #endif
 
-static void die2(int err, const char *what)
-{
-    fprintf(stderr, "%s failed: %s\n", what, strerror(err));
-    abort();
-}
-
-static void die(const char *what)
-{
-    die2(errno, what);
-}
-
 static ssize_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb)
 {
     int ret;
@@ -277,7 +267,21 @@ static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb)
     return nbytes;
 }
 
-static void posix_aio_notify_event(void);
+static void posix_aio_notify_event(void)
+{
+    /* Write 8 bytes to be compatible with eventfd.  */
+    static const uint64_t val = 1;
+    ssize_t ret;
+
+    do {
+        ret = write(posix_aio_state->wfd, &val, sizeof(val));
+    } while (ret < 0 && errno == EINTR);
+
+    if (ret < 0 && errno != EAGAIN) {
+        fprintf(stderr, "write() failed: %s\n", strerror(errno));
+        abort();
+    }
+}
 
 static void *aio_thread(void *unused)
 {
@@ -502,22 +506,6 @@ static int posix_aio_flush(void *opaque)
     return !!s->first_aio;
 }
 
-static PosixAioState *posix_aio_state;
-
-static void posix_aio_notify_event(void)
-{
-    /* Write 8 bytes to be compatible with eventfd.  */
-    static const uint64_t val = 1;
-    ssize_t ret;
-
-    do {
-        ret = write(posix_aio_state->wfd, &val, sizeof(val));
-    } while (ret < 0 && errno == EINTR);
-
-    if (ret < 0 && errno != EAGAIN)
-        die("write()");
-}
-
 static void paio_remove(struct qemu_paiocb *acb)
 {
     struct qemu_paiocb **pacb;
-- 
1.7.3.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]