+/*
+ * Init functions
+ */
+extern int parse_options(int, char **);
+extern int init_random_state(struct thread_data *);
+
+/*
+ * File setup/shutdown
+ */
+extern void close_files(struct thread_data *);
+extern int setup_files(struct thread_data *);
+
+/*
+ * This is a pretty crappy semaphore implementation, but with the use that fio
+ * has (just signalling start/go conditions), it doesn't have to be better.
+ * Naturally this would not work for any type of contended semaphore or
+ * for real locking.
+ */
+static inline void fio_sem_init(volatile int *sem, int val)
+{
+ *sem = val;
+}
+
+static inline void fio_sem_down(volatile int *sem)
+{
+ while (*sem == 0)
+ usleep(10000);
+
+ (*sem)--;
+}
+
+static inline void fio_sem_up(volatile int *sem)
+{
+ (*sem)++;
+}
+
+/*
+ * If logging output to a file, stderr should go to both stderr and f_err
+ */
+#define log_err(args...) do { \
+ fprintf(f_err, ##args); \
+ if (f_err != stderr) \
+ fprintf(stderr, ##args); \
+ } while (0)
+
+struct ioengine_ops {
+ char name[16];
+ int version;
+ int flags;
+ int (*setup)(struct thread_data *);
+ int (*init)(struct thread_data *);
+ int (*prep)(struct thread_data *, struct io_u *);
+ int (*queue)(struct thread_data *, struct io_u *);
+ int (*getevents)(struct thread_data *, int, int, struct timespec *);
+ struct io_u *(*event)(struct thread_data *, int);
+ int (*cancel)(struct thread_data *, struct io_u *);
+ void (*cleanup)(struct thread_data *);
+ int (*sync)(struct thread_data *, struct fio_file *);
+ void *data;
+ void *dlhandle;
+};
+
+#define FIO_IOOPS_VERSION 2
+
+extern struct ioengine_ops *load_ioengine(struct thread_data *, char *);
+extern void close_ioengine(struct thread_data *);
+
+/*
+ * Mark unused variables passed to ops functions as unused, to silence gcc
+ */
+#define fio_unused __attribute((__unused__))
+
+#define for_each_file(td, f, i) \
+ for ((i) = 0, (f) = &(td)->files[(i)]; (i) < (td)->nr_files; (i)++, (f) = &(td)->files[(i)])
+