perf-hooks.h 874 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef PERF_UTIL_PERF_HOOKS_H
  3. #define PERF_UTIL_PERF_HOOKS_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef void (*perf_hook_func_t)(void *ctx);
  8. struct perf_hook_desc {
  9. const char * const hook_name;
  10. perf_hook_func_t * const p_hook_func;
  11. void *hook_ctx;
  12. };
  13. extern void perf_hooks__invoke(const struct perf_hook_desc *);
  14. extern void perf_hooks__recover(void);
  15. #define PERF_HOOK(name) \
  16. extern struct perf_hook_desc __perf_hook_desc_##name; \
  17. static inline void perf_hooks__invoke_##name(void) \
  18. { \
  19. perf_hooks__invoke(&__perf_hook_desc_##name); \
  20. }
  21. #include "perf-hooks-list.h"
  22. #undef PERF_HOOK
  23. extern int
  24. perf_hooks__set_hook(const char *hook_name,
  25. perf_hook_func_t hook_func,
  26. void *hook_ctx);
  27. extern perf_hook_func_t
  28. perf_hooks__get_hook(const char *hook_name);
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32. #endif