Wang Nan | a074865 | 2016-11-26 07:03:28 +0000 | [diff] [blame] | 1 | #ifndef PERF_UTIL_PERF_HOOKS_H |
| 2 | #define PERF_UTIL_PERF_HOOKS_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
Wang Nan | 8ad85e9 | 2016-11-26 07:03:29 +0000 | [diff] [blame] | 8 | typedef void (*perf_hook_func_t)(void *ctx); |
Wang Nan | a074865 | 2016-11-26 07:03:28 +0000 | [diff] [blame] | 9 | struct perf_hook_desc { |
| 10 | const char * const hook_name; |
| 11 | perf_hook_func_t * const p_hook_func; |
Wang Nan | 8ad85e9 | 2016-11-26 07:03:29 +0000 | [diff] [blame] | 12 | void *hook_ctx; |
Wang Nan | a074865 | 2016-11-26 07:03:28 +0000 | [diff] [blame] | 13 | }; |
| 14 | |
| 15 | extern void perf_hooks__invoke(const struct perf_hook_desc *); |
| 16 | extern void perf_hooks__recover(void); |
| 17 | |
| 18 | #define PERF_HOOK(name) \ |
| 19 | extern struct perf_hook_desc __perf_hook_desc_##name; \ |
| 20 | static 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 | |
| 28 | extern int |
| 29 | perf_hooks__set_hook(const char *hook_name, |
Wang Nan | 8ad85e9 | 2016-11-26 07:03:29 +0000 | [diff] [blame] | 30 | perf_hook_func_t hook_func, |
| 31 | void *hook_ctx); |
Wang Nan | a074865 | 2016-11-26 07:03:28 +0000 | [diff] [blame] | 32 | |
| 33 | extern perf_hook_func_t |
| 34 | perf_hooks__get_hook(const char *hook_name); |
| 35 | |
| 36 | #ifdef __cplusplus |
| 37 | } |
| 38 | #endif |
| 39 | #endif |