Lines Matching refs:sym
21 #define INTERRUPTER(sym) \ argument
22 if (real_##sym == NULL) \
23 __init_##sym(); \
29 #define CALL_FUNCTION_1(sym, ret, type1) \ argument
30 ret (*real_##sym)(type1) = NULL; \
31 ret sym(type1 arg1) { \
32 INTERRUPTER(sym) \
33 return real_##sym(arg1); \
36 #define CALL_FUNCTION_2(sym, ret, type1, type2) \ argument
37 ret (*real_##sym)(type1, type2) = NULL; \
38 ret sym(type1 arg1, type2 arg2) { \
39 INTERRUPTER(sym) \
40 return real_##sym(arg1, arg2); \
43 #define CALL_FUNCTION_3(sym, ret, type1, type2, type3) \ argument
44 ret (*real_##sym)(type1, type2, type3) = NULL; \
45 ret sym(type1 arg1, type2 arg2, type3 arg3) { \
46 INTERRUPTER(sym) \
47 return real_##sym(arg1, arg2, arg3); \
50 #define CALL_FUNCTION_4(sym, ret, type1, type2, type3, type4) \ argument
51 ret (*real_##sym)(type1, type2, type3, type4) = NULL; \
52 ret sym(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
53 INTERRUPTER(sym) \
54 return real_##sym(arg1, arg2, arg3, arg4); \
57 #define CALL_FUNCTION_5(sym, ret, type1, type2, type3, type4, type5) \ argument
58 ret (*real_##sym)(type1, type2, type3, type4, type5) = NULL; \
59 ret sym(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
60 INTERRUPTER(sym) \
61 return real_##sym(arg1, arg2, arg3, arg4, arg5); \
64 #define DEFINE_INTERCEPT_N(N, sym, ret, ...) \ argument
65 static void __init_##sym(void); \
66 CONCATENATE(CALL_FUNCTION_, N)(sym, ret, __VA_ARGS__) \
67 static void __init_##sym(void) { \
68 real_##sym = dlsym(RTLD_NEXT, #sym); \
69 if (real_##sym == NULL) { \
70 fprintf(stderr, "Error hooking " #sym ": %s\n", dlerror()); \
79 #define DEFINE_INTERCEPT(sym, ret, ...) DEFINE_INTERCEPT_N(INTERCEPT_NARG(__VA_ARGS__), sym, ret, _… argument