diff options
Diffstat (limited to 'include/linux/jiffies.h')
| -rw-r--r-- | include/linux/jiffies.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 043376920f51..c8d5f207c3d4 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h | |||
| @@ -47,8 +47,8 @@ | |||
| 47 | * - (NOM / DEN) fits in (32 - LSH) bits. | 47 | * - (NOM / DEN) fits in (32 - LSH) bits. |
| 48 | * - (NOM % DEN) fits in (32 - LSH) bits. | 48 | * - (NOM % DEN) fits in (32 - LSH) bits. |
| 49 | */ | 49 | */ |
| 50 | #define SH_DIV(NOM,DEN,LSH) ( ((NOM / DEN) << LSH) \ | 50 | #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ |
| 51 | + (((NOM % DEN) << LSH) + DEN / 2) / DEN) | 51 | + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN)) |
| 52 | 52 | ||
| 53 | /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ | 53 | /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ |
| 54 | #define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) | 54 | #define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) |
| @@ -115,6 +115,21 @@ static inline u64 get_jiffies_64(void) | |||
| 115 | ((long)(a) - (long)(b) >= 0)) | 115 | ((long)(a) - (long)(b) >= 0)) |
| 116 | #define time_before_eq(a,b) time_after_eq(b,a) | 116 | #define time_before_eq(a,b) time_after_eq(b,a) |
| 117 | 117 | ||
| 118 | /* Same as above, but does so with platform independent 64bit types. | ||
| 119 | * These must be used when utilizing jiffies_64 (i.e. return value of | ||
| 120 | * get_jiffies_64() */ | ||
| 121 | #define time_after64(a,b) \ | ||
| 122 | (typecheck(__u64, a) && \ | ||
| 123 | typecheck(__u64, b) && \ | ||
| 124 | ((__s64)(b) - (__s64)(a) < 0)) | ||
| 125 | #define time_before64(a,b) time_after64(b,a) | ||
| 126 | |||
| 127 | #define time_after_eq64(a,b) \ | ||
| 128 | (typecheck(__u64, a) && \ | ||
| 129 | typecheck(__u64, b) && \ | ||
| 130 | ((__s64)(a) - (__s64)(b) >= 0)) | ||
| 131 | #define time_before_eq64(a,b) time_after_eq64(b,a) | ||
| 132 | |||
| 118 | /* | 133 | /* |
| 119 | * Have the 32 bit jiffies value wrap 5 minutes after boot | 134 | * Have the 32 bit jiffies value wrap 5 minutes after boot |
| 120 | * so jiffies wrap bugs show up earlier. | 135 | * so jiffies wrap bugs show up earlier. |
