--- libaitsched/src/hooks.c 2012/05/30 08:34:44 1.6.4.2 +++ libaitsched/src/hooks.c 2012/05/30 08:51:49 1.6.4.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: hooks.c,v 1.6.4.2 2012/05/30 08:34:44 misho Exp $ +* $Id: hooks.c,v 1.6.4.3 2012/05/30 08:51:49 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -107,7 +107,6 @@ sched_hook_cancel(void *task, void *arg __unused) sched_task_t *t = task; struct kevent chg[1]; struct timespec timeout = { 0, 0 }; - uintptr_t ident; if (!t || !TASK_ROOT(t)) return (void*) -1; @@ -130,14 +129,12 @@ sched_hook_cancel(void *task, void *arg __unused) kevent(TASK_ROOT(t)->root_kq, chg, 1, NULL, 0, &timeout); break; case taskALARM: - if (TASK_DATA(t)) - ident = (uintptr_t) TASK_DATA(t); - else - ident = (uintptr_t) TASK_FUNC(t); #ifdef __NetBSD__ - EV_SET(&chg[0], ident, EVFILT_TIMER, EV_DELETE, 0, 0, (intptr_t) ident); + EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, EV_DELETE, + 0, 0, (intptr_t) TASK_DATA(t)); #else - EV_SET(&chg[0], ident, EVFILT_TIMER, EV_DELETE, 0, 0, (void*) ident); + EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, EV_DELETE, + 0, 0, (void*) TASK_DATA(t)); #endif kevent(TASK_ROOT(t)->root_kq, chg, 1, NULL, 0, &timeout); break; @@ -227,24 +224,18 @@ sched_hook_alarm(void *task, void *arg __unused) sched_task_t *t = task; struct kevent chg[1]; struct timespec timeout = { 0, 0 }; - uintptr_t ident; if (!t || !TASK_ROOT(t)) return (void*) -1; - if (TASK_DATA(t)) - ident = (uintptr_t) TASK_DATA(t); - else - ident = (uintptr_t) TASK_FUNC(t); - #ifdef __NetBSD__ - EV_SET(&chg[0], ident, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, + EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, t->task_val.ts.tv_sec * 1000 + t->task_val.ts.tv_nsec / 1000000, - (intptr_t) ident); + (intptr_t) TASK_DATA(t)); #else - EV_SET(&chg[0], ident, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, + EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, t->task_val.ts.tv_sec * 1000 + t->task_val.ts.tv_nsec / 1000000, - (void*) ident); + (void*) TASK_DATA(t)); #endif if (kevent(TASK_ROOT(t)->root_kq, chg, 1, NULL, 0, &timeout) == -1) { if (TASK_ROOT(t)->root_hooks.hook_exec.exception) @@ -274,7 +265,6 @@ sched_hook_fetch(void *root, void *arg __unused) struct kevent evt[1], res[KQ_EVENTS]; register int i; int en; - uintptr_t ident; if (!r) return NULL; @@ -466,11 +456,7 @@ sched_hook_fetch(void *root, void *arg __unused) break; case EVFILT_TIMER: TAILQ_FOREACH_SAFE(task, &r->root_alarm, task_node, tmp) { - if (TASK_DATA(task)) - ident = (uintptr_t) TASK_DATA(task); - else - ident = (uintptr_t) TASK_FUNC(task); - if (ident != ((uintptr_t) res[i].udata)) + if ((uintptr_t) TASK_DATA(task) != ((uintptr_t) res[i].udata)) continue; /* remove alarm handle */ #ifdef HAVE_LIBPTHREAD