| 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 | |
| 14 | int add_option(struct fio_option *); |
| 15 | void invalidate_profile_options(const char *); |
| 16 | extern char *exec_profile; |
| 17 | |
| 18 | void add_opt_posval(const char *, const char *, const char *); |
| 19 | void del_opt_posval(const char *, const char *); |
| 20 | struct thread_data; |
| 21 | void fio_options_free(struct thread_data *); |
| 22 | char *get_name_idx(char *, int); |
| 23 | int set_name_idx(char *, size_t, char *, int); |
| 24 | |
| 25 | extern char client_sockaddr_str[]; /* used with --client option */ |
| 26 | |
| 27 | extern struct fio_option fio_options[FIO_MAX_OPTS]; |
| 28 | |
| 29 | extern 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 | |
| 38 | extern void fio_option_mark_set(struct thread_options *, struct fio_option *); |
| 39 | |
| 40 | static 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 | |
| 50 | static 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 | |
| 62 | extern struct fio_option *fio_option_find(const char *name); |
| 63 | extern unsigned int fio_get_kb_base(void *); |
| 64 | |
| 65 | #endif |