blob: baf82bf227acbadfb1ca547584bd123e121b3f14 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Taeung Song20105ca2016-04-14 16:53:18 +09002#ifndef __PERF_CONFIG_H
3#define __PERF_CONFIG_H
4
5#include <stdbool.h>
6#include <linux/list.h>
7
8struct perf_config_item {
9 char *name;
10 char *value;
Taeung Song08d090c2016-11-04 15:44:22 +090011 bool from_system_config;
Taeung Song20105ca2016-04-14 16:53:18 +090012 struct list_head node;
13};
14
15struct perf_config_section {
16 char *name;
17 struct list_head items;
Taeung Song08d090c2016-11-04 15:44:22 +090018 bool from_system_config;
Taeung Song20105ca2016-04-14 16:53:18 +090019 struct list_head node;
20};
21
22struct perf_config_set {
23 struct list_head sections;
24};
25
Taeung Song41840d22016-06-23 17:55:17 +090026extern const char *config_exclusive_filename;
27
28typedef int (*config_fn_t)(const char *, const char *, void *);
29int perf_default_config(const char *, const char *, void *);
30int perf_config(config_fn_t fn, void *);
Arnaldo Carvalho de Melo25ce4bb2017-06-27 11:44:58 -030031int perf_config_int(int *dest, const char *, const char *);
32int perf_config_u64(u64 *dest, const char *, const char *);
Taeung Song41840d22016-06-23 17:55:17 +090033int perf_config_bool(const char *, const char *);
34int config_error_nonbool(const char *);
35const char *perf_etc_perfconfig(void);
36
Taeung Song20105ca2016-04-14 16:53:18 +090037struct perf_config_set *perf_config_set__new(void);
38void perf_config_set__delete(struct perf_config_set *set);
Taeung Song08d090c2016-11-04 15:44:22 +090039int perf_config_set__collect(struct perf_config_set *set, const char *file_name,
Taeung Songc6fc0182016-11-04 15:44:20 +090040 const char *var, const char *value);
Taeung Song8a0a9c72016-06-23 23:14:31 +090041void perf_config__init(void);
42void perf_config__exit(void);
43void perf_config__refresh(void);
44
45/**
46 * perf_config_sections__for_each - iterate thru all the sections
47 * @list: list_head instance to iterate
48 * @section: struct perf_config_section iterator
49 */
50#define perf_config_sections__for_each_entry(list, section) \
51 list_for_each_entry(section, list, node)
52
53/**
54 * perf_config_items__for_each - iterate thru all the items
55 * @list: list_head instance to iterate
56 * @item: struct perf_config_item iterator
57 */
58#define perf_config_items__for_each_entry(list, item) \
59 list_for_each_entry(item, list, node)
60
61/**
62 * perf_config_set__for_each - iterate thru all the config section-item pairs
63 * @set: evlist instance to iterate
64 * @section: struct perf_config_section iterator
65 * @item: struct perf_config_item iterator
66 */
67#define perf_config_set__for_each_entry(set, section, item) \
68 perf_config_sections__for_each_entry(&set->sections, section) \
69 perf_config_items__for_each_entry(&section->items, item)
Taeung Song20105ca2016-04-14 16:53:18 +090070
71#endif /* __PERF_CONFIG_H */