xref: /openbmc/linux/tools/perf/util/config.h (revision f3539c12)
1 #ifndef __PERF_CONFIG_H
2 #define __PERF_CONFIG_H
3 
4 #include <stdbool.h>
5 #include <linux/list.h>
6 
7 struct perf_config_item {
8 	char *name;
9 	char *value;
10 	struct list_head node;
11 };
12 
13 struct perf_config_section {
14 	char *name;
15 	struct list_head items;
16 	struct list_head node;
17 };
18 
19 struct perf_config_set {
20 	struct list_head sections;
21 };
22 
23 extern const char *config_exclusive_filename;
24 
25 typedef int (*config_fn_t)(const char *, const char *, void *);
26 int perf_default_config(const char *, const char *, void *);
27 int perf_config(config_fn_t fn, void *);
28 int perf_config_int(const char *, const char *);
29 u64 perf_config_u64(const char *, const char *);
30 int perf_config_bool(const char *, const char *);
31 int config_error_nonbool(const char *);
32 const char *perf_etc_perfconfig(void);
33 
34 struct perf_config_set *perf_config_set__new(void);
35 void perf_config_set__delete(struct perf_config_set *set);
36 void perf_config__init(void);
37 void perf_config__exit(void);
38 void perf_config__refresh(void);
39 
40 /**
41  * perf_config_sections__for_each - iterate thru all the sections
42  * @list: list_head instance to iterate
43  * @section: struct perf_config_section iterator
44  */
45 #define perf_config_sections__for_each_entry(list, section)	\
46         list_for_each_entry(section, list, node)
47 
48 /**
49  * perf_config_items__for_each - iterate thru all the items
50  * @list: list_head instance to iterate
51  * @item: struct perf_config_item iterator
52  */
53 #define perf_config_items__for_each_entry(list, item)	\
54         list_for_each_entry(item, list, node)
55 
56 /**
57  * perf_config_set__for_each - iterate thru all the config section-item pairs
58  * @set: evlist instance to iterate
59  * @section: struct perf_config_section iterator
60  * @item: struct perf_config_item iterator
61  */
62 #define perf_config_set__for_each_entry(set, section, item)			\
63 	perf_config_sections__for_each_entry(&set->sections, section)		\
64 	perf_config_items__for_each_entry(&section->items, item)
65 
66 #endif /* __PERF_CONFIG_H */
67