Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/timer.h
Show All 33 Lines | |||||
#include <linux/types.h> | #include <linux/types.h> | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/callout.h> | #include <sys/callout.h> | ||||
struct timer_list { | struct timer_list { | ||||
struct callout callout; | struct callout callout; | ||||
#if __LinuxKPI_version >= 40015 | |||||
void (*function) (struct timer_list *); | |||||
/* | |||||
* This field is temporary until we can get all users up to date | |||||
* and fix the callback routine in linux_compat.c | |||||
*/ | |||||
struct timer_list *data; | |||||
#else | |||||
void (*function) (unsigned long); | void (*function) (unsigned long); | ||||
unsigned long data; | unsigned long data; | ||||
#endif | |||||
int expires; | int expires; | ||||
}; | }; | ||||
extern unsigned long linux_timer_hz_mask; | extern unsigned long linux_timer_hz_mask; | ||||
#define TIMER_IRQSAFE 0x0001 | #define TIMER_IRQSAFE 0x0001 | ||||
#if __LinuxKPI_version >= 40015 | |||||
#define from_timer(var, cb, field) \ | |||||
container_of(cb, typeof(*var), field) | |||||
#define __timer_setup(timer, func) do { \ | |||||
(timer)->function = (func); \ | |||||
(timer)->data = (timer); \ | |||||
callout_init(&(timer)->callout, 1); \ | |||||
} while (0) | |||||
#define timer_setup(timer, func, flags) \ | |||||
__timer_setup((timer), (func)) | |||||
#else | |||||
#define setup_timer(timer, func, dat) do { \ | #define setup_timer(timer, func, dat) do { \ | ||||
(timer)->function = (func); \ | (timer)->function = (func); \ | ||||
(timer)->data = (dat); \ | (timer)->data = (dat); \ | ||||
callout_init(&(timer)->callout, 1); \ | callout_init(&(timer)->callout, 1); \ | ||||
} while (0) | } while (0) | ||||
#define __setup_timer(timer, func, dat, flags) do { \ | #define __setup_timer(timer, func, dat, flags) do { \ | ||||
CTASSERT(((flags) & ~TIMER_IRQSAFE) == 0); \ | CTASSERT(((flags) & ~TIMER_IRQSAFE) == 0); \ | ||||
setup_timer(timer, func, dat); \ | setup_timer(timer, func, dat); \ | ||||
} while (0) | } while (0) | ||||
#define init_timer(timer) do { \ | #define init_timer(timer) do { \ | ||||
(timer)->function = NULL; \ | (timer)->function = NULL; \ | ||||
(timer)->data = 0; \ | (timer)->data = 0; \ | ||||
callout_init(&(timer)->callout, 1); \ | callout_init(&(timer)->callout, 1); \ | ||||
} while (0) | } while (0) | ||||
#endif | |||||
extern void mod_timer(struct timer_list *, int); | extern void mod_timer(struct timer_list *, int); | ||||
extern void add_timer(struct timer_list *); | extern void add_timer(struct timer_list *); | ||||
extern void add_timer_on(struct timer_list *, int cpu); | extern void add_timer_on(struct timer_list *, int cpu); | ||||
#define del_timer(timer) (void)callout_stop(&(timer)->callout) | #define del_timer(timer) (void)callout_stop(&(timer)->callout) | ||||
#define del_timer_sync(timer) (void)callout_drain(&(timer)->callout) | #define del_timer_sync(timer) (void)callout_drain(&(timer)->callout) | ||||
#define timer_pending(timer) callout_pending(&(timer)->callout) | #define timer_pending(timer) callout_pending(&(timer)->callout) | ||||
#define round_jiffies(j) \ | #define round_jiffies(j) \ | ||||
((int)(((j) + linux_timer_hz_mask) & ~linux_timer_hz_mask)) | ((int)(((j) + linux_timer_hz_mask) & ~linux_timer_hz_mask)) | ||||
#define round_jiffies_relative(j) round_jiffies(j) | #define round_jiffies_relative(j) round_jiffies(j) | ||||
#define round_jiffies_up(j) round_jiffies(j) | #define round_jiffies_up(j) round_jiffies(j) | ||||
#define round_jiffies_up_relative(j) round_jiffies_up(j) | #define round_jiffies_up_relative(j) round_jiffies_up(j) | ||||
#endif /* _LINUX_TIMER_H_ */ | #endif /* _LINUX_TIMER_H_ */ |