#include <unistd.h>
#include <errno.h>
#include <assert.h>
-#include "fio.h"
-#include "os.h"
+
+#include "../fio.h"
+#include "../os.h"
+
+#ifdef FIO_HAVE_LIBAIO
#define ev_to_iou(ev) (struct io_u *) ((unsigned long) (ev)->obj)
break;
} while (1);
- return (int) -r;
+ if (r < 0)
+ r = -r;
+
+ return (int) r;
}
static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
memset(ld, 0, sizeof(*ld));
if (io_queue_init(td->iodepth, &ld->aio_ctx)) {
td_verror(td, errno);
+ free(ld);
return 1;
}
return 0;
}
-struct ioengine_ops ioengine = {
+static struct ioengine_ops ioengine = {
.name = "libaio",
.version = FIO_IOOPS_VERSION,
.init = fio_libaio_init,
.event = fio_libaio_event,
.cleanup = fio_libaio_cleanup,
};
+
+#else /* FIO_HAVE_LIBAIO */
+
+/*
+ * When we have a proper configure system in place, we simply wont build
+ * and install this io engine. For now install a crippled version that
+ * just complains and fails to load.
+ */
+static int fio_libaio_init(struct thread_data fio_unused *td)
+{
+ fprintf(stderr, "fio: libaio not available\n");
+ return 1;
+}
+
+static struct ioengine_ops ioengine = {
+ .name = "libaio",
+ .version = FIO_IOOPS_VERSION,
+ .init = fio_libaio_init,
+};
+
+#endif
+
+static void fio_init fio_libaio_register(void)
+{
+ register_ioengine(&ioengine);
+}
+
+static void fio_exit fio_libaio_unregister(void)
+{
+ unregister_ioengine(&ioengine);
+}