Project

General

Profile

Bug #713 ยป evh_track.diff

qhwt+dfly, 07/11/2007 04:58 AM

View differences:

sys/eventhandler.h 11 Jul 2007 04:31:07 -0000
TAILQ_ENTRY(eventhandler_entry) ee_link;
int ee_priority;
void *ee_arg;
const char *ee_name;
};
struct eventhandler_list
......
};
typedef struct eventhandler_entry *eventhandler_tag;
extern int eventhandler_show_invoked_funcs;
/*
* Fast handler lists require the eventhandler list be present
......
struct eventhandler_entry *_ep = TAILQ_FIRST(&(_el->el_entries)); \
\
while (_ep != NULL) { \
if (eventhandler_show_invoked_funcs) \
kprintf("FAST_INVOKE(" #name ") %s\n", _ep->ee_name); \
((struct eventhandler_entry_ ## name *)_ep)->eh_func(_ep->ee_arg , ## args); \
_ep = TAILQ_NEXT(_ep, ee_link); \
} \
} while (0)
#define EVENTHANDLER_FAST_REGISTER(name, func, arg, priority) \
eventhandler_register(Xeventhandler_list_ ## name, #name, func, arg, priority)
eventhandler_register(Xeventhandler_list_ ## name, #name, #func, func, arg, priority)
#define EVENTHANDLER_FAST_DEREGISTER(name, tag) \
eventhandler_deregister(Xeventhandler_list ## name, tag)
......
for (_ep = TAILQ_FIRST(&(_el->el_entries)); \
_ep != NULL; \
_ep = TAILQ_NEXT(_ep, ee_link)) { \
if (eventhandler_show_invoked_funcs) \
kprintf("INVOKE(" #name ") %s\n", _ep->ee_name); \
((struct eventhandler_entry_ ## name *)_ep)->eh_func(_ep->ee_arg , ## args); \
} \
} \
} while (0)
#define EVENTHANDLER_REGISTER(name, func, arg, priority) \
eventhandler_register(NULL, #name, func, arg, priority)
eventhandler_register(NULL, #name, #func, func, arg, priority)
#define EVENTHANDLER_DEREGISTER(name, tag) \
do { \
......
#ifdef _KERNEL
extern eventhandler_tag eventhandler_register(struct eventhandler_list *list,
char *name,
const char *fname,
void *func,
void *arg,
int priority);
kern/subr_eventhandler.c 11 Jul 2007 04:13:07 -0000
MALLOC_DEFINE(M_EVENTHANDLER, "eventhandler", "Event handler records");
int eventhandler_show_invoked_funcs = 0;
/* List of 'slow' lists */
static TAILQ_HEAD(, eventhandler_list) eventhandler_lists;
static int eventhandler_lists_initted = 0;
......
* if all priorities are identical.
*/
eventhandler_tag
eventhandler_register(struct eventhandler_list *list, char *name,
void *func, void *arg, int priority)
eventhandler_register(struct eventhandler_list *list, char *name,
const char *funcname, void *func, void *arg, int priority)
{
struct eventhandler_entry_generic *eg;
struct eventhandler_entry *ep;
......
eg->func = func;
eg->ee.ee_arg = arg;
eg->ee.ee_priority = priority;
eg->ee.ee_name = funcname;
/* sort it into the list */
for (ep = TAILQ_FIRST(&list->el_entries);
    (1-1/1)