X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fhook.h;h=325d218671c7a98f080a5a3df12d8b56ff2cc846;hb=14c7af39fb81f679d7d666951af9816d0e4e5903;hp=bd68e0966304b2af1ce455fbb8a85d29fc915762;hpb=47e763400230ba5cd55c377db531a4610f3c00ea;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/hook.h b/ltt/branches/poly/lttv/lttv/hook.h index bd68e096..325d2186 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 @@ -41,7 +42,10 @@ typedef GArray LttvHooks; * functions. Hook removal does not change list order. */ -#define LTTV_PRIO_DEFAULT 0 +#define LTTV_PRIO_DEFAULT 50 +#define LTTV_PRIO_HIGH 0 +#define LTTV_PRIO_LOW 99 + typedef gint LttvHookPrio; /* Create and destroy a list of hooks */ @@ -58,7 +62,7 @@ void lttv_hooks_add(LttvHooks *h, LttvHook f, void *hook_data, LttvHookPrio p); /* Add a list of hooks to the list h */ -void lttv_hooks_add_list(LttvHooks *h, LttvHooks *list); +void lttv_hooks_add_list(LttvHooks *h, const LttvHooks *list); /* Remove a hook from the list. Return the hook data. */ @@ -73,7 +77,7 @@ void lttv_hooks_remove_data(LttvHooks *h, LttvHook f, void *hook_data); /* Remove a list of hooks from the hooks list in h. */ -void lttv_hooks_remove_data_list(LttvHooks *h, LttvHooks *list); +void lttv_hooks_remove_list(LttvHooks *h, LttvHooks *list); /* Return the number of hooks in the list */ @@ -89,6 +93,7 @@ void lttv_hooks_get(LttvHooks *h, unsigned i, LttvHook *f, void **hook_data, /* Remove the specified hook. The position of the following hooks may change */ +/* The hook is removed from the list event if its ref_count is higher than 1 */ void lttv_hooks_remove_by_position(LttvHooks *h, unsigned i); @@ -118,8 +123,10 @@ 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; /* Create and destroy a hooks by id list */ @@ -140,7 +147,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 */