blob: 1a59a6b43f8bd622772af23000bed69e9693c4a9 [file] [log] [blame]
Taeung Song20105ca2016-04-14 16:53:18 +09001#ifndef __PERF_CONFIG_H
2#define __PERF_CONFIG_H
3
4#include <stdbool.h>
5#include <linux/list.h>
6
7struct perf_config_item {
8 char *name;
9 char *value;
Taeung Song08d090c2016-11-04 15:44:22 +090010 bool from_system_config;
Taeung Song20105ca2016-04-14 16:53:18 +090011 struct list_head node;
12};
13
14struct perf_config_section {
15 char *name;
16 struct list_head items;
Taeung Song08d090c2016-11-04 15:44:22 +090017 bool from_system_config;
Taeung Song20105ca2016-04-14 16:53:18 +090018 struct list_head node;
19};
20
21struct perf_config_set {
22 struct list_head sections;
23};
24
Taeung Song41840d22016-06-23 17:55:17 +090025extern const char *config_exclusive_filename;
26
27typedef int (*config_fn_t)(const char *, const char *, void *);
28int perf_default_config(const char *, const char *, void *);
29int perf_config(config_fn_t fn, void *);
30int perf_config_int(const char *, const char *);
31u64 perf_config_u64(const char *, const char *);
32int perf_config_bool(const char *, const char *);
33int config_error_nonbool(const char *);
34const char *perf_etc_perfconfig(void);
35
Taeung Song20105ca2016-04-14 16:53:18 +090036struct perf_config_set *perf_config_set__new(void);
37void perf_config_set__delete(struct perf_config_set *set);
Taeung Song08d090c2016-11-04 15:44:22 +090038int perf_config_set__collect(struct perf_config_set *set, const char *file_name,
Taeung Songc6fc0182016-11-04 15:44:20 +090039 const char *var, const char *value);
Taeung Song8a0a9c72016-06-23 23:14:31 +090040void perf_config__init(void);
41void perf_config__exit(void);
42void perf_config__refresh(void);
43
44/**
45 * perf_config_sections__for_each - iterate thru all the sections
46 * @list: list_head instance to iterate
47 * @section: struct perf_config_section iterator
48 */
49#define perf_config_sections__for_each_entry(list, section) \
50 list_for_each_entry(section, list, node)
51
52/**
53 * perf_config_items__for_each - iterate thru all the items
54 * @list: list_head instance to iterate
55 * @item: struct perf_config_item iterator
56 */
57#define perf_config_items__for_each_entry(list, item) \
58 list_for_each_entry(item, list, node)
59
60/**
61 * perf_config_set__for_each - iterate thru all the config section-item pairs
62 * @set: evlist instance to iterate
63 * @section: struct perf_config_section iterator
64 * @item: struct perf_config_item iterator
65 */
66#define perf_config_set__for_each_entry(set, section, item) \
67 perf_config_sections__for_each_entry(&set->sections, section) \
68 perf_config_items__for_each_entry(&section->items, item)
Taeung Song20105ca2016-04-14 16:53:18 +090069
70#endif /* __PERF_CONFIG_H */