51 lines
1.5 KiB
C
51 lines
1.5 KiB
C
|
#pragma once
|
||
|
|
||
|
#define HZ 100
|
||
|
/*
|
||
|
* Have the 32 bit jiffies value wrap 5 minutes after boot
|
||
|
* so jiffies wrap bugs show up earlier.
|
||
|
*/
|
||
|
//#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
|
||
|
#define INITIAL_JIFFIES 0
|
||
|
|
||
|
extern unsigned long volatile jiffies;
|
||
|
|
||
|
|
||
|
#define time_after(unknown, known) ((long)(known) - (long)(unknown) < 0)
|
||
|
#define time_before(unknown, known) ((long)(unknown) - (long)(known) < 0)
|
||
|
#define time_after_eq(unknown, known) ((long)(unknown) - (long)(known) >= 0)
|
||
|
#define time_before_eq(unknown, known) ((long)(known) - (long)(unknown) >= 0)
|
||
|
|
||
|
/*
|
||
|
* Calculate whether a is in the range of [b, c].
|
||
|
*/
|
||
|
#define time_in_range(a,b,c) \
|
||
|
(time_after_eq(a,b) && \
|
||
|
time_before_eq(a,c))
|
||
|
|
||
|
/*
|
||
|
* Calculate whether a is in the range of [b, c).
|
||
|
*/
|
||
|
#define time_in_range_open(a,b,c) \
|
||
|
(time_after_eq(a,b) && \
|
||
|
time_before(a,c))
|
||
|
|
||
|
/*
|
||
|
* These four macros compare jiffies and 'a' for convenience.
|
||
|
*/
|
||
|
|
||
|
/* time_is_before_jiffies(a) return true if a is before jiffies */
|
||
|
#define time_is_before_jiffies(a) time_after(jiffies, a)
|
||
|
|
||
|
/* time_is_after_jiffies(a) return true if a is after jiffies */
|
||
|
#define time_is_after_jiffies(a) time_before(jiffies, a)
|
||
|
|
||
|
/* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/
|
||
|
#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a)
|
||
|
|
||
|
/* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/
|
||
|
#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a)
|
||
|
|
||
|
unsigned int jiffies_to_msecs(const unsigned long j);
|
||
|
unsigned int jiffies_to_usecs(const unsigned long j);
|