From d3ae536bb9ae50bc90ce44049f5bf21cef1848f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 19 Sep 2008 09:26:14 +0000 Subject: [PATCH] * Made callout_pending() and callout_active() real functions instead of macros; that makes drivers using it more independent from internal net_timer changes. * Correctly implemented callout_active() using the new is_timer_running() stack function. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27632 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/compat/freebsd_network/callout.c | 17 +++++++++++++++++ .../compat/freebsd_network/compat/sys/callout.h | 8 +++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/libs/compat/freebsd_network/callout.c b/src/libs/compat/freebsd_network/callout.c index 7c7c0be1fa..f9374392f7 100644 --- a/src/libs/compat/freebsd_network/callout.c +++ b/src/libs/compat/freebsd_network/callout.c @@ -27,6 +27,9 @@ handle_callout(struct net_timer *timer, void *data) } +// #pragma mark - + + void callout_init_mtx(struct callout *c, struct mtx *mtx, int flags) { @@ -63,3 +66,17 @@ _callout_stop_safe(struct callout *c, int safe) return gStack->cancel_timer(&c->c_timer) ? 1 : 0; } + +int +callout_pending(struct callout *c) +{ + return gStack->is_timer_active(&c->c_timer); +} + + +int +callout_active(struct callout *c) +{ + return gStack->is_timer_running(&c->c_timer); +} + diff --git a/src/libs/compat/freebsd_network/compat/sys/callout.h b/src/libs/compat/freebsd_network/compat/sys/callout.h index f6c5a67d02..cf8b0ccfd2 100644 --- a/src/libs/compat/freebsd_network/compat/sys/callout.h +++ b/src/libs/compat/freebsd_network/compat/sys/callout.h @@ -22,16 +22,14 @@ struct callout { #define CALLOUT_MPSAFE 0x0001 void callout_init_mtx(struct callout *c, struct mtx *mutex, int flags); -int callout_reset(struct callout *, int, void (*)(void *), void *); +int callout_reset(struct callout *c, int, void (*func)(void *), void *arg); +int callout_pending(struct callout *c); +int callout_active(struct callout *c); #define callout_drain(c) _callout_stop_safe(c, 1) #define callout_stop(c) _callout_stop_safe(c, 0) int _callout_stop_safe(struct callout *, int); -#define callout_pending(c) ((c)->c_timer.due > 0) -#define callout_active(c) ((c)->c_timer.due == -1) - // TODO: there is currently no way to find out about this! - static inline void callout_init(struct callout *c, int mpsafe)