perf-hooks.h 835 B

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