config.h 2.1 KB

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