Split out the is_power_of_2() from fio.h and make it independent.
Signed-off-by: Jens Axboe <axboe@fb.com>
#include <libaio.h>
#include "../fio.h"
#include <libaio.h>
#include "../fio.h"
+#include "../lib/pow2.h"
static int fio_libaio_commit(struct thread_data *td);
static int fio_libaio_commit(struct thread_data *td);
#include <string.h>
#include "fio.h"
#include <string.h>
#include "fio.h"
static char __run_str[REAL_MAX_JOBS + 1];
static char run_str[__THREAD_RUNSTR_SZ(REAL_MAX_JOBS)];
static char __run_str[REAL_MAX_JOBS + 1];
static char run_str[__THREAD_RUNSTR_SZ(REAL_MAX_JOBS)];
return min(td->o.min_bs[DDIR_TRIM], min_bs);
}
return min(td->o.min_bs[DDIR_TRIM], min_bs);
}
-static inline int is_power_of_2(uint64_t val)
-{
- return (val != 0 && ((val & (val - 1)) == 0));
-}
-
static inline int td_async_processing(struct thread_data *td)
{
return (td->flags & TD_F_NEED_LOCK) != 0;
static inline int td_async_processing(struct thread_data *td)
{
return (td->flags & TD_F_NEED_LOCK) != 0;
#include "graph.h"
#include "gclient.h"
#include "printing.h"
#include "graph.h"
#include "gclient.h"
#include "printing.h"
static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
struct group_run_stats *rs);
static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
struct group_run_stats *rs);
#include "lib/rand.h"
#include "lib/axmap.h"
#include "err.h"
#include "lib/rand.h"
#include "lib/axmap.h"
#include "err.h"
struct io_completion_data {
int nr; /* input */
struct io_completion_data {
int nr; /* input */
--- /dev/null
+#ifndef FIO_POW2_H
+#define FIO_POW2_H
+
+#include <inttypes.h>
+
+static inline int is_power_of_2(uint64_t val)
+{
+ return (val != 0 && ((val & (val - 1)) == 0));
+}
+
+#endif
#include "options.h"
#include "minmax.h"
#include "lib/ieee754.h"
#include "options.h"
#include "minmax.h"
#include "lib/ieee754.h"
#ifdef CONFIG_ARITHMETIC
#include "y.tab.h"
#ifdef CONFIG_ARITHMETIC
#include "y.tab.h"
+ if (o->pow2 && !is_power_of_2(ull)) {
+ log_err("%s: must be a power-of-2\n", o->name);
+ return 1;
+ }
if (o->maxval && ull > o->maxval) {
log_err("max value out of range: %llu"
if (o->maxval && ull > o->maxval) {
log_err("max value out of range: %llu"
int is_seconds; /* time value with seconds base */
int is_time; /* time based value */
int no_warn_def;
int is_seconds; /* time value with seconds base */
int is_time; /* time based value */
int no_warn_def;
+ int pow2; /* must be a power-of-2 */
};
typedef int (str_cb_fn)(void *, char *);
};
typedef int (str_cb_fn)(void *, char *);
#include "json.h"
#include "lib/getrusage.h"
#include "idletime.h"
#include "json.h"
#include "lib/getrusage.h"
#include "idletime.h"
struct fio_mutex *stat_mutex;
struct fio_mutex *stat_mutex;