+static void wait_for_event(struct timeval *tv)
+{
+ struct solarisaio_data *sd;
+ struct io_u *io_u;
+ aio_result_t *res;
+
+ res = aiowait(tv);
+ if (res == (aio_result_t *) -1) {
+ int err = errno;
+
+ if (err != EINVAL) {
+ log_err("fio: solarisaio got %d in aiowait\n", err);
+ exit(err);
+ }
+ return;
+ } else if (!res)
+ return;
+
+ io_u = container_of(res, struct io_u, resultp);
+ sd = io_u->engine_data;
+
+ if (io_u->resultp.aio_return >= 0) {
+ io_u->resid = io_u->xfer_buflen - io_u->resultp.aio_return;
+ io_u->error = 0;
+ } else
+ io_u->error = io_u->resultp.aio_errno;
+
+ /*
+ * For SIGIO, we need a write barrier between the two, so that
+ * the ->aio_pending store is seen after the ->aio_events store
+ */
+ sd->aio_events[sd->aio_pending] = io_u;
+ write_barrier();
+ sd->aio_pending++;
+ sd->nr--;
+}
+