Fix for non-git versions
[fio.git] / options.h
1 #ifndef FIO_OPTION_H
2 #define FIO_OPTION_H
3
4 #define FIO_MAX_OPTS            512
5
6 #include <string.h>
7 #include "parse.h"
8 #include "flist.h"
9
10 #define td_var_offset(var)      ((size_t) &((struct thread_options *)0)->var)
11
12 int add_option(struct fio_option *);
13 void invalidate_profile_options(const char *);
14 extern char *exec_profile;
15
16 void add_opt_posval(const char *, const char *, const char *);
17 void del_opt_posval(const char *, const char *);
18 struct thread_data;
19 void fio_options_free(struct thread_data *);
20
21 extern struct fio_option fio_options[FIO_MAX_OPTS];
22
23 static inline int o_match(struct fio_option *o, const char *opt)
24 {
25         if (!strcmp(o->name, opt))
26                 return 1;
27         else if (o->alias && !strcmp(o->alias, opt))
28                 return 1;
29
30         return 0;
31 }
32
33 static inline struct fio_option *find_option(struct fio_option *options,
34                                              const char *opt)
35 {
36         struct fio_option *o;
37
38         for (o = &options[0]; o->name; o++)
39                 if (o_match(o, opt))
40                         return o;
41
42         return NULL;
43 }
44
45 struct opt_group {
46         const char *name;
47         unsigned int mask;
48 };
49
50 enum opt_category {
51         __FIO_OPT_C_GENERAL     = 0,
52         __FIO_OPT_C_IO,
53         __FIO_OPT_C_FILE,
54         __FIO_OPT_C_STAT,
55         __FIO_OPT_C_LOG,
56         __FIO_OPT_C_PROFILE,
57         __FIO_OPT_C_NR,
58
59         FIO_OPT_C_GENERAL       = (1U << __FIO_OPT_C_GENERAL),
60         FIO_OPT_C_IO            = (1U << __FIO_OPT_C_IO),
61         FIO_OPT_C_FILE          = (1U << __FIO_OPT_C_FILE),
62         FIO_OPT_C_STAT          = (1U << __FIO_OPT_C_STAT),
63         FIO_OPT_C_LOG           = (1U << __FIO_OPT_C_LOG),
64         FIO_OPT_C_PROFILE       = (1U << __FIO_OPT_C_PROFILE),
65         FIO_OPT_C_INVALID       = (1U << __FIO_OPT_C_NR),
66 };
67
68 enum opt_category_group {
69         __FIO_OPT_G_RATE        = 0,
70         __FIO_OPT_G_ZONE,
71         __FIO_OPT_G_RWMIX,
72         __FIO_OPT_G_VERIFY,
73         __FIO_OPT_G_TRIM,
74         __FIO_OPT_G_IOLOG,
75         __FIO_OPT_G_IO_DEPTH,
76         __FIO_OPT_G_IO_FLOW,
77         __FIO_OPT_G_DESC,
78         __FIO_OPT_G_FILENAME,
79         __FIO_OPT_G_IO_BASIC,
80         __FIO_OPT_G_CGROUP,
81         __FIO_OPT_G_RUNTIME,
82         __FIO_OPT_G_PROCESS,
83         __FIO_OPT_G_CRED,
84         __FIO_OPT_G_CLOCK,
85         __FIO_OPT_G_IO_TYPE,
86         __FIO_OPT_G_THINKTIME,
87         __FIO_OPT_G_RANDOM,
88         __FIO_OPT_G_IO_BUF,
89         __FIO_OPT_G_TIOBENCH,
90         __FIO_OPT_G_NR,
91
92         FIO_OPT_G_RATE          = (1U << __FIO_OPT_G_RATE),
93         FIO_OPT_G_ZONE          = (1U << __FIO_OPT_G_ZONE),
94         FIO_OPT_G_RWMIX         = (1U << __FIO_OPT_G_RWMIX),
95         FIO_OPT_G_VERIFY        = (1U << __FIO_OPT_G_VERIFY),
96         FIO_OPT_G_TRIM          = (1U << __FIO_OPT_G_TRIM),
97         FIO_OPT_G_IOLOG         = (1U << __FIO_OPT_G_IOLOG),
98         FIO_OPT_G_IO_DEPTH      = (1U << __FIO_OPT_G_IO_DEPTH),
99         FIO_OPT_G_IO_FLOW       = (1U << __FIO_OPT_G_IO_FLOW),
100         FIO_OPT_G_DESC          = (1U << __FIO_OPT_G_DESC),
101         FIO_OPT_G_FILENAME      = (1U << __FIO_OPT_G_FILENAME),
102         FIO_OPT_G_IO_BASIC      = (1U << __FIO_OPT_G_IO_BASIC),
103         FIO_OPT_G_CGROUP        = (1U << __FIO_OPT_G_CGROUP),
104         FIO_OPT_G_RUNTIME       = (1U << __FIO_OPT_G_RUNTIME),
105         FIO_OPT_G_PROCESS       = (1U << __FIO_OPT_G_PROCESS),
106         FIO_OPT_G_CRED          = (1U << __FIO_OPT_G_CRED),
107         FIO_OPT_G_CLOCK         = (1U << __FIO_OPT_G_CLOCK),
108         FIO_OPT_G_IO_TYPE       = (1U << __FIO_OPT_G_IO_TYPE),
109         FIO_OPT_G_THINKTIME     = (1U << __FIO_OPT_G_THINKTIME),
110         FIO_OPT_G_RANDOM        = (1U << __FIO_OPT_G_RANDOM),
111         FIO_OPT_G_IO_BUF        = (1U << __FIO_OPT_G_IO_BUF),
112         FIO_OPT_G_TIOBENCH      = (1U << __FIO_OPT_G_TIOBENCH),
113         FIO_OPT_G_INVALID       = (1U << __FIO_OPT_G_NR),
114 };
115
116 extern struct opt_group *opt_group_from_mask(unsigned int *mask);
117 extern struct opt_group *opt_group_cat_from_mask(unsigned int *mask);
118 extern struct fio_option *fio_option_find(const char *name);
119 extern unsigned int fio_get_kb_base(void *);
120
121 #endif