1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_CONFIG_H
3 #define __PERF_CONFIG_H
6 #include <linux/list.h>
8 struct perf_config_item {
11 bool from_system_config;
12 struct list_head node;
15 struct perf_config_section {
17 struct list_head items;
18 bool from_system_config;
19 struct list_head node;
22 struct perf_config_set {
23 struct list_head sections;
26 extern const char *config_exclusive_filename;
28 typedef int (*config_fn_t)(const char *, const char *, void *);
30 int perf_default_config(const char *, const char *, void *);
31 int perf_config(config_fn_t fn, void *);
32 int perf_config_set(struct perf_config_set *set,
33 config_fn_t fn, void *data);
34 int perf_config_int(int *dest, const char *, const char *);
35 int perf_config_u8(u8 *dest, const char *name, const char *value);
36 int perf_config_u64(u64 *dest, const char *, const char *);
37 int perf_config_bool(const char *, const char *);
38 int config_error_nonbool(const char *);
39 const char *perf_etc_perfconfig(void);
40 const char *perf_home_perfconfig(void);
41 int perf_config_system(void);
42 int perf_config_global(void);
44 struct perf_config_set *perf_config_set__new(void);
45 struct perf_config_set *perf_config_set__load_file(const char *file);
46 void perf_config_set__delete(struct perf_config_set *set);
47 int perf_config_set__collect(struct perf_config_set *set, const char *file_name,
48 const char *var, const char *value);
49 void perf_config__exit(void);
50 void perf_config__refresh(void);
53 * perf_config_sections__for_each - iterate thru all the sections
54 * @list: list_head instance to iterate
55 * @section: struct perf_config_section iterator
57 #define perf_config_sections__for_each_entry(list, section) \
58 list_for_each_entry(section, list, node)
61 * perf_config_items__for_each - iterate thru all the items
62 * @list: list_head instance to iterate
63 * @item: struct perf_config_item iterator
65 #define perf_config_items__for_each_entry(list, item) \
66 list_for_each_entry(item, list, node)
69 * perf_config_set__for_each - iterate thru all the config section-item pairs
70 * @set: evlist instance to iterate
71 * @section: struct perf_config_section iterator
72 * @item: struct perf_config_item iterator
74 #define perf_config_set__for_each_entry(set, section, item) \
75 perf_config_sections__for_each_entry(&set->sections, section) \
76 perf_config_items__for_each_entry(§ion->items, item)
78 #endif /* __PERF_CONFIG_H */