X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fhook.h;h=90f50b0d54a462e99448c0879b1664a3694df552;hb=d052ffc307fc3321aeec9fc318ca300558dbc5f3;hp=193714c6d987407a726c707005f6d0a3c6b7a041;hpb=8436038a4e160b8916eee165b2a897d05d4bca2f;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/hook.h b/ltt/branches/poly/lttv/lttv/hook.h index 193714c6..90f50b0d 100644 --- a/ltt/branches/poly/lttv/lttv/hook.h +++ b/ltt/branches/poly/lttv/lttv/hook.h @@ -22,6 +22,7 @@ #define HOOK_H #include +#include /* A hook is a function to call with the supplied hook data, and with call site specific data (e.g., hooks for events are called with a @@ -122,8 +123,14 @@ gboolean lttv_hooks_call_check_merge(LttvHooks *h1, void *call_data1, /* Sometimes different hooks need to be called based on the case. The case is represented by an unsigned integer id */ -typedef GPtrArray LttvHooksById; +typedef struct _LttvHooksById { + GPtrArray *index; + GArray *array; +} LttvHooksById; +/* macro to calculate the hook ID of a facility/event pair. */ +#define GET_HOOK_ID(fac_id, ev_id) \ + ( (guint)fac_id | ((guint)ev_id << (8*sizeof(NUM_FACILITIES))) ) /* Create and destroy a hooks by id list */ @@ -144,7 +151,14 @@ unsigned lttv_hooks_by_id_max_id(LttvHooksById *h); /* Get the list of hooks for an id, NULL if none exists */ -LttvHooks *lttv_hooks_by_id_get(LttvHooksById *h, unsigned id); +static inline LttvHooks *lttv_hooks_by_id_get(LttvHooksById *h, unsigned id) +{ + LttvHooks *ret; + if(likely(id < h->index->len)) ret = h->index->pdata[id]; + else ret = NULL; + + return ret; +} /* Remove the list of hooks associated with an id */