+/*
+ * Log exports
+ */
+extern int read_iolog_get(struct thread_data *, struct io_u *);
+extern void write_iolog_put(struct thread_data *, struct io_u *);
+extern int init_iolog(struct thread_data *td);
+extern void log_io_piece(struct thread_data *, struct io_u *);
+extern void prune_io_piece_log(struct thread_data *);
+extern void write_iolog_close(struct thread_data *);
+
+/*
+ * Logging
+ */
+extern void add_clat_sample(struct thread_data *, int, unsigned long);
+extern void add_slat_sample(struct thread_data *, int, unsigned long);
+extern void add_bw_sample(struct thread_data *, int);
+extern void show_run_stats(void);
+extern void init_disk_util(struct thread_data *);
+extern void update_rusage_stat(struct thread_data *);
+extern void update_io_ticks(void);
+extern void disk_util_timer_arm(void);
+extern void setup_log(struct io_log **);
+extern void finish_log(struct thread_data *, struct io_log *, const char *);
+extern int setup_rate(struct thread_data *);
+
+/*
+ * Time functions
+ */
+extern void time_init(void);
+extern unsigned long utime_since(struct timeval *, struct timeval *);
+extern unsigned long mtime_since(struct timeval *, struct timeval *);
+extern unsigned long mtime_since_now(struct timeval *);
+extern unsigned long time_since_now(struct timeval *);
+extern unsigned long mtime_since_genesis(void);
+extern void __usec_sleep(unsigned int);
+extern void usec_sleep(struct thread_data *, unsigned long);
+extern void rate_throttle(struct thread_data *, unsigned long, unsigned int);
+
+/*
+ * 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 *);
+extern int file_invalidate_cache(struct thread_data *, struct fio_file *);
+
+/*
+ * ETA/status stuff
+ */
+extern void print_thread_status(void);
+extern void print_status_init(int);
+
+/*
+ * Thread life cycle. Once a thread has a runstate beyond TD_INITIALIZED, it
+ * will never back again. It may cycle between running/verififying/fsyncing.
+ * Once the thread reaches TD_EXITED, it is just waiting for the core to
+ * reap it.
+ */
+enum {
+ TD_NOT_CREATED = 0,
+ TD_CREATED,
+ TD_INITIALIZED,
+ TD_RUNNING,
+ TD_VERIFYING,
+ TD_FSYNCING,
+ TD_EXITED,
+ TD_REAPED,
+};
+
+/*
+ * Verify helpers
+ */
+extern void populate_verify_io_u(struct thread_data *, struct io_u *);
+extern int get_next_verify(struct thread_data *td, struct io_u *);
+extern int do_io_u_verify(struct thread_data *, struct io_u **);
+
+/*
+ * Memory helpers
+ */
+extern int fio_pin_memory(void);
+extern void fio_unpin_memory(void);
+extern int allocate_io_mem(struct thread_data *);
+extern void free_io_mem(struct thread_data *);
+
+/*
+ * io unit handling
+ */
+#define queue_full(td) list_empty(&(td)->io_u_freelist)
+extern struct io_u *__get_io_u(struct thread_data *);
+extern struct io_u *get_io_u(struct thread_data *, struct fio_file *);
+extern void put_io_u(struct thread_data *, struct io_u *);
+extern void ios_completed(struct thread_data *, struct io_completion_data *);
+extern void io_completed(struct thread_data *, struct io_u *, struct io_completion_data *);
+
+/*
+ * io engine entry points
+ */
+extern int td_io_init(struct thread_data *);
+extern int td_io_prep(struct thread_data *, struct io_u *);
+extern int td_io_queue(struct thread_data *, struct io_u *);
+extern int td_io_sync(struct thread_data *, struct fio_file *);
+extern int td_io_getevents(struct thread_data *, int, int, struct timespec *);
+
+/*
+ * 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 *);
+ void *data;
+ void *dlhandle;
+};
+
+#define FIO_IOOPS_VERSION 3
+
+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_td(td, i) \
+ for ((i) = 0, (td) = &threads[0]; (i) < (int) thread_number; (i)++, (td)++)
+#define for_each_file(td, f, i) \
+ for ((i) = 0, (f) = &(td)->files[0]; (i) < (int) (td)->nr_files; (i)++, (f)++)
+