1 /* 2 * Copyright 2007, Hugo Santos. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _FBSD_COMPAT_SYS_CALLOUT_H_ 6 #define _FBSD_COMPAT_SYS_CALLOUT_H_ 7 8 #include <sys/haiku-module.h> 9 10 #include <sys/mutex.h> 11 #include <sys/queue.h> 12 13 14 struct callout { 15 struct net_timer c_timer; 16 void * c_arg; 17 void (*c_func)(void *); 18 struct mtx * c_mtx; 19 int c_flags; 20 }; 21 22 23 void callout_init_mtx(struct callout *c, struct mtx *mutex, int flags); 24 int callout_reset(struct callout *, int, void (*)(void *), void *); 25 26 #define callout_drain(c) _callout_stop_safe(c, 1) 27 #define callout_stop(c) _callout_stop_safe(c, 0) 28 int _callout_stop_safe(struct callout *, int); 29 30 #define callout_pending(c) ((c)->c_timer.due > 0) 31 #define callout_active(c) ((c)->c_timer.due == -1) 32 // TODO: there is currently no way to find out about this! 33 34 35 static inline void 36 callout_init(struct callout *c, int mpsafe) 37 { 38 if (mpsafe) 39 callout_init_mtx(c, NULL, 0); 40 else 41 callout_init_mtx(c, &Giant, 0); 42 } 43 44 #endif /* _FBSD_COMPAT_SYS_CALLOUT_H_ */ 45