options: split out option grouping code
[fio.git] / options.h
... / ...
CommitLineData
1#ifndef FIO_OPTION_H
2#define FIO_OPTION_H
3
4#define FIO_MAX_OPTS 512
5
6#include <string.h>
7#include <inttypes.h>
8#include "parse.h"
9#include "flist.h"
10#include "lib/types.h"
11
12#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
13
14int add_option(struct fio_option *);
15void invalidate_profile_options(const char *);
16extern char *exec_profile;
17
18void add_opt_posval(const char *, const char *, const char *);
19void del_opt_posval(const char *, const char *);
20struct thread_data;
21void fio_options_free(struct thread_data *);
22char *get_name_idx(char *, int);
23int set_name_idx(char *, size_t, char *, int);
24
25extern char client_sockaddr_str[]; /* used with --client option */
26
27extern struct fio_option fio_options[FIO_MAX_OPTS];
28
29extern bool __fio_option_is_set(struct thread_options *, unsigned int off);
30
31#define fio_option_is_set(__td, name) \
32({ \
33 const unsigned int off = td_var_offset(name); \
34 bool __r = __fio_option_is_set((__td), off); \
35 __r; \
36})
37
38extern void fio_option_mark_set(struct thread_options *, struct fio_option *);
39
40static inline bool o_match(struct fio_option *o, const char *opt)
41{
42 if (!strcmp(o->name, opt))
43 return true;
44 else if (o->alias && !strcmp(o->alias, opt))
45 return true;
46
47 return false;
48}
49
50static inline struct fio_option *find_option(struct fio_option *options,
51 const char *opt)
52{
53 struct fio_option *o;
54
55 for (o = &options[0]; o->name; o++)
56 if (o_match(o, opt))
57 return o;
58
59 return NULL;
60}
61
62extern struct fio_option *fio_option_find(const char *name);
63extern unsigned int fio_get_kb_base(void *);
64
65#endif