blob: 838d5797bc1ef4fdb1df0390d2db7d2a54070ad3 [file] [log] [blame]
Wang Nana0748652016-11-26 07:03:28 +00001#ifndef PERF_UTIL_PERF_HOOKS_H
2#define PERF_UTIL_PERF_HOOKS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
Wang Nan8ad85e92016-11-26 07:03:29 +00008typedef void (*perf_hook_func_t)(void *ctx);
Wang Nana0748652016-11-26 07:03:28 +00009struct perf_hook_desc {
10 const char * const hook_name;
11 perf_hook_func_t * const p_hook_func;
Wang Nan8ad85e92016-11-26 07:03:29 +000012 void *hook_ctx;
Wang Nana0748652016-11-26 07:03:28 +000013};
14
15extern void perf_hooks__invoke(const struct perf_hook_desc *);
16extern void perf_hooks__recover(void);
17
18#define PERF_HOOK(name) \
19extern struct perf_hook_desc __perf_hook_desc_##name; \
20static inline void perf_hooks__invoke_##name(void) \
21{ \
22 perf_hooks__invoke(&__perf_hook_desc_##name); \
23}
24
25#include "perf-hooks-list.h"
26#undef PERF_HOOK
27
28extern int
29perf_hooks__set_hook(const char *hook_name,
Wang Nan8ad85e92016-11-26 07:03:29 +000030 perf_hook_func_t hook_func,
31 void *hook_ctx);
Wang Nana0748652016-11-26 07:03:28 +000032
33extern perf_hook_func_t
34perf_hooks__get_hook(const char *hook_name);
35
36#ifdef __cplusplus
37}
38#endif
39#endif