00001 #ifndef IG_PROF_IG_PROF_MACROS_H
00002 # define IG_PROF_IG_PROF_MACROS_H
00003
00004
00005
00006
00007 #define IGPROF_MERGE2(a,b) a##b
00008 #define IGPROF_MERGE3(a,b,c) a##b##c
00009
00010 #define IGPROF_ARGS0()
00011 #define IGPROF_ARGS1(a) a
00012 #define IGPROF_ARGS2(a,b) a,b
00013 #define IGPROF_ARGS3(a,b,c) a,b,c
00014 #define IGPROF_ARGS4(a,b,c,d) a,b,c,d
00015
00016 #define IGPROF_ARGSREST0()
00017 #define IGPROF_ARGSREST1(a) ,a
00018 #define IGPROF_ARGSREST2(a,b) ,a,b
00019 #define IGPROF_ARGSREST3(a,b,c) ,a,b,c
00020 #define IGPROF_ARGSREST4(a,b,c,d) ,a,b,c,d
00021
00022 #define IGPROF_DUAL_HOOK(n, ret, dofun, id1, id2, args, argnames, fun, v, lib) \
00023 IGPROF_LIBHOOK(n, ret, dofun, id1, args, argnames, fun, 0, 0) \
00024 IGPROF_LIBHOOK(n, ret, dofun, id2, args, argnames, fun, v, lib)
00025
00026 #define IGPROF_HOOK(n, ret, dofun, id, args, argnames, fun) \
00027 IGPROF_LIBHOOK(n, ret, dofun, id, args, argnames, fun, 0, 0)
00028
00029 #define IGPROF_LIBHOOK(n, ret, dofun, id, args, argnames, fun, v, lib) \
00030 typedef ret igprof_##dofun##_t (IGPROF_MERGE2(IGPROF_ARGS,n) args); \
00031 static ret dofun (IgHook::SafeData<igprof_##dofun##_t> &hook \
00032 IGPROF_MERGE2(IGPROF_ARGSREST,n) args); \
00033 static ret IGPROF_MERGE3(dofun,_stub_,id)(IGPROF_MERGE2(IGPROF_ARGS,n) args);\
00034 static IgHook::TypedData<ret(IGPROF_MERGE2(IGPROF_ARGS,n) args)> IGPROF_MERGE3(dofun,_hook,id) \
00035 = { { 0, fun, v, lib, &IGPROF_MERGE3(dofun,_stub_,id), 0, 0, 0 } };\
00036 static ret IGPROF_MERGE3(dofun,_stub_,id) (IGPROF_MERGE2(IGPROF_ARGS,n) args) \
00037 { return dofun (IGPROF_MERGE3(dofun,_hook,id).typed \
00038 IGPROF_MERGE2(IGPROF_ARGSREST,n) argnames); }
00039
00040 #if IGPROF_DEBUG
00041 # define IGPROF_ASSERT(expr) \
00042 ((void)((expr) ? 1 : IgProf::panic(__FILE__,__LINE__,__PRETTY_FUNCTION__,#expr)))
00043 #else
00044 # define IGPROF_ASSERT(expr)
00045 #endif
00046
00047
00048 #if IGPROF_VERBOSE
00049 # define IGPROF_TRACE(expr) do { IgProf::debug expr; } while (0)
00050 #else
00051 # define IGPROF_TRACE(expr) do { ; } while (0)
00052 #endif
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #endif // IG_PROF_IG_PROF_MACROS_H