Enable crc32c accelleration for arm64 on OSX
[fio.git] / parse.h
CommitLineData
e1f36503
JA
1#ifndef FIO_PARSE_H
2#define FIO_PARSE_H
3
b5f4ef37 4#include <inttypes.h>
9f988e2e
JA
5#include "flist.h"
6
e1f36503
JA
7/*
8 * Option types
9 */
10enum fio_opt_type {
07b3232d
JA
11 FIO_OPT_INVALID = 0,
12 FIO_OPT_STR,
5fff9543 13 FIO_OPT_STR_ULL,
5f6ddf1e 14 FIO_OPT_STR_MULTI,
e1f36503
JA
15 FIO_OPT_STR_VAL,
16 FIO_OPT_STR_VAL_TIME,
17 FIO_OPT_STR_STORE,
18 FIO_OPT_RANGE,
19 FIO_OPT_INT,
5fff9543 20 FIO_OPT_ULL,
13335ddb 21 FIO_OPT_BOOL,
83349190 22 FIO_OPT_FLOAT_LIST,
e1f36503 23 FIO_OPT_STR_SET,
8f39afa7 24 FIO_OPT_STR_VAL_ZONE,
15ca150e 25 FIO_OPT_DEPRECATED,
c47537ee 26 FIO_OPT_SOFT_DEPRECATED,
c26438ad 27 FIO_OPT_UNSUPPORTED, /* keep this last */
e1f36503
JA
28};
29
b1ec1da6
JA
30/*
31 * Match a possible value string with the integer option.
32 */
33struct value_pair {
34 const char *ival; /* string option */
5fff9543 35 unsigned long long oval;/* output value */
7837213b 36 const char *help; /* help text for sub option */
ebadc0ce 37 int orval; /* OR value */
c44b1ff5 38 void *cb; /* sub-option callback */
b1ec1da6
JA
39};
40
07a2919d 41#define OPT_LEN_MAX 8192
34a8f35f 42#define PARSE_MAX_VP 32
b1ec1da6 43
e1f36503
JA
44/*
45 * Option define
46 */
47struct fio_option {
ee738499 48 const char *name; /* option name */
e8b0e958 49 const char *lname; /* long option name */
03b74b3e 50 const char *alias; /* possible old allowed name */
ee738499
JA
51 enum fio_opt_type type; /* option type */
52 unsigned int off1; /* potential parameters */
e1f36503 53 unsigned int off2;
f90eff5a
JA
54 unsigned int off3;
55 unsigned int off4;
6eaf09d6
SL
56 unsigned int off5;
57 unsigned int off6;
5fff9543 58 unsigned long long maxval; /* max and min value */
63f29372 59 int minval;
83349190
YH
60 double maxfp; /* max and min floating value */
61 double minfp;
20eb06bd 62 unsigned int interval; /* client hint for suitable interval */
83349190 63 unsigned int maxlen; /* max length */
76a43db4 64 int neg; /* negate value stored */
3b8b7135 65 int prio;
ee738499
JA
66 void *cb; /* callback */
67 const char *help; /* help text for option */
68 const char *def; /* default setting */
f5b6bb85 69 struct value_pair posval[PARSE_MAX_VP];/* possible values */
afdf9352 70 const char *parent; /* parent option */
d71c154c 71 int hide; /* hide if parent isn't set */
a4ed77fe 72 int hide_on_set; /* hide on set, not on unset */
90265353
JA
73 const char *inverse; /* if set, apply opposite action to this option */
74 struct fio_option *inv_opt; /* cached lookup */
9109883a 75 int (*verify)(const struct fio_option *, void *);
07b3232d 76 const char *prof_name; /* only valid for specific profile */
7b504edd 77 void *prof_opts;
b5f4ef37
JA
78 uint64_t category; /* what type of option */
79 uint64_t group; /* who to group with */
90265353 80 void *gui_data;
0de5b26f 81 int is_seconds; /* time value with seconds base */
88038bc7 82 int is_time; /* time based value */
c8931876 83 int no_warn_def;
0f38bbef 84 int pow2; /* must be a power-of-2 */
43f466e6 85 int no_free;
e1f36503
JA
86};
87
9109883a
BVA
88extern int parse_option(char *, const char *, const struct fio_option *,
89 const struct fio_option **, void *,
90 struct flist_head *);
91extern void sort_options(char **, const struct fio_option *, int);
92extern int parse_cmd_option(const char *t, const char *l,
93 const struct fio_option *, void *,
94 struct flist_head *);
95extern int show_cmd_help(const struct fio_option *, const char *);
96extern void fill_default_options(void *, const struct fio_option *);
13335ddb 97extern void options_init(struct fio_option *);
9109883a
BVA
98extern void options_mem_dupe(const struct fio_option *, void *);
99extern void options_free(const struct fio_option *, void *);
e1f36503
JA
100
101extern void strip_blank_front(char **);
102extern void strip_blank_end(char *);
88038bc7 103extern int str_to_decimal(const char *, long long *, int, void *, int, int);
9af4a244 104extern int check_str_bytes(const char *p, long long *val, void *data);
0de5b26f 105extern int check_str_time(const char *p, long long *val, int);
88038bc7 106extern int str_to_float(const char *str, double *val, int is_time);
e1f36503 107
a893c261 108extern int string_distance(const char *s1, const char *s2);
3701636d 109extern int string_distance_ok(const char *s1, int dist);
a893c261 110
e1f36503
JA
111/*
112 * Handlers for the options
113 */
b4692828 114typedef int (fio_opt_str_fn)(void *, const char *);
63f29372
JA
115typedef int (fio_opt_str_val_fn)(void *, long long *);
116typedef int (fio_opt_int_fn)(void *, int *);
e1f36503 117
f0fdbcaf 118struct thread_options;
9109883a
BVA
119static inline void *td_var(void *to, const struct fio_option *o,
120 unsigned int offset)
f0fdbcaf 121{
041c462d
JA
122 void *ret;
123
f0fdbcaf 124 if (o->prof_opts)
041c462d
JA
125 ret = o->prof_opts;
126 else
127 ret = to;
f0fdbcaf 128
291945b1 129 return (void *) ((uintptr_t) ret + offset);
f0fdbcaf 130}
e1f36503 131
7bb59102
JA
132static inline int parse_is_percent(unsigned long long val)
133{
0cf2af99 134 return val >= -101ULL;
7bb59102
JA
135}
136
8f39afa7 137#define ZONE_BASE_VAL ((-1ULL >> 1) + 1)
f248a525
AD
138static inline int parse_is_percent_uncapped(unsigned long long val)
139{
8f39afa7
AD
140 return ZONE_BASE_VAL + -1U < val;
141}
142
143static inline int parse_is_zone(unsigned long long val)
144{
145 return (val - ZONE_BASE_VAL) <= -1U;
f248a525
AD
146}
147
c2292325
JA
148struct print_option {
149 struct flist_head list;
150 char *name;
151 char *value;
152};
153
e1f36503 154#endif