config.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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__exit(void);
  35. void perf_config__refresh(void);
  36. /**
  37. * perf_config_sections__for_each - iterate thru all the sections
  38. * @list: list_head instance to iterate
  39. * @section: struct perf_config_section iterator
  40. */
  41. #define perf_config_sections__for_each_entry(list, section) \
  42. list_for_each_entry(section, list, node)
  43. /**
  44. * perf_config_items__for_each - iterate thru all the items
  45. * @list: list_head instance to iterate
  46. * @item: struct perf_config_item iterator
  47. */
  48. #define perf_config_items__for_each_entry(list, item) \
  49. list_for_each_entry(item, list, node)
  50. /**
  51. * perf_config_set__for_each - iterate thru all the config section-item pairs
  52. * @set: evlist instance to iterate
  53. * @section: struct perf_config_section iterator
  54. * @item: struct perf_config_item iterator
  55. */
  56. #define perf_config_set__for_each_entry(set, section, item) \
  57. perf_config_sections__for_each_entry(&set->sections, section) \
  58. perf_config_items__for_each_entry(&section->items, item)
  59. #endif /* __PERF_CONFIG_H */