Add round_jiffies_up(), local_clock() and __setup_timer() to the LinuxKPI.

Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D11871
This commit is contained in:
Mark Johnston 2017-08-08 04:34:02 +00:00
parent 48dac28d63
commit c0589825fd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=322213
2 changed files with 26 additions and 9 deletions

View file

@ -36,14 +36,16 @@
#include <sys/proc.h>
#include <sys/sched.h>
#include <sys/sleepqueue.h>
#include <sys/time.h>
#include <linux/bitmap.h>
#include <linux/compat.h>
#include <linux/completion.h>
#include <linux/mm_types.h>
#include <linux/pid.h>
#include <linux/slab.h>
#include <linux/mm_types.h>
#include <linux/string.h>
#include <linux/bitmap.h>
#include <linux/time.h>
#include <asm/atomic.h>
@ -150,4 +152,13 @@ int linux_schedule_timeout(int timeout);
#define io_schedule() schedule()
#define io_schedule_timeout(timeout) schedule_timeout(timeout)
static inline uint64_t
local_clock(void)
{
struct timespec ts;
nanotime(&ts);
return ((uint64_t)ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec);
}
#endif /* _LINUX_SCHED_H_ */

View file

@ -46,15 +46,20 @@ struct timer_list {
extern unsigned long linux_timer_hz_mask;
#define setup_timer(timer, func, dat) \
do { \
#define TIMER_IRQSAFE 0x0001
#define setup_timer(timer, func, dat) do { \
(timer)->function = (func); \
(timer)->data = (dat); \
callout_init(&(timer)->timer_callout, 1); \
} while (0)
#define init_timer(timer) \
do { \
#define __setup_timer(timer, func, dat, flags) do { \
CTASSERT(((flags) & ~TIMER_IRQSAFE) == 0); \
setup_timer(timer, func, dat); \
} while (0)
#define init_timer(timer) do { \
(timer)->function = NULL; \
(timer)->data = 0; \
callout_init(&(timer)->timer_callout, 1); \
@ -67,9 +72,10 @@ extern void add_timer_on(struct timer_list *, int cpu);
#define del_timer(timer) callout_stop(&(timer)->timer_callout)
#define del_timer_sync(timer) callout_drain(&(timer)->timer_callout)
#define timer_pending(timer) callout_pending(&(timer)->timer_callout)
#define round_jiffies(j) \
#define round_jiffies(j) \
((unsigned long)(((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_relative(j) round_jiffies_up(j)
#endif /* _LINUX_TIMER_H_ */