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