aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/jiffies.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/jiffies.h')
-rw-r--r--include/linux/jiffies.h29
1 files changed, 19 insertions, 10 deletions
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index aded9b1ac5ca..05e3c2c7a8cf 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -39,9 +39,6 @@
39# error Invalid value of HZ. 39# error Invalid value of HZ.
40#endif 40#endif
41 41
42/* LATCH is used in the interval timer and ftape setup. */
43#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
44
45/* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can 42/* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can
46 * improve accuracy by shifting LSH bits, hence calculating: 43 * improve accuracy by shifting LSH bits, hence calculating:
47 * (NOM << LSH) / DEN 44 * (NOM << LSH) / DEN
@@ -54,18 +51,30 @@
54#define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ 51#define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \
55 + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN)) 52 + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN))
56 53
57/* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ 54#ifdef CLOCK_TICK_RATE
58#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) 55/* LATCH is used in the interval timer and ftape setup. */
56# define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
57
58/*
59 * HZ is the requested value. However the CLOCK_TICK_RATE may not allow
60 * for exactly HZ. So SHIFTED_HZ is high res HZ ("<< 8" is for accuracy)
61 */
62# define SHIFTED_HZ (SH_DIV(CLOCK_TICK_RATE, LATCH, 8))
63#else
64# define SHIFTED_HZ (HZ << 8)
65#endif
59 66
60/* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */ 67/* TICK_NSEC is the time between ticks in nsec assuming SHIFTED_HZ */
61#define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8)) 68#define TICK_NSEC (SH_DIV(1000000UL * 1000, SHIFTED_HZ, 8))
62 69
63/* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */ 70/* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */
64#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) 71#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
65 72
66/* TICK_USEC_TO_NSEC is the time between ticks in nsec assuming real ACTHZ and */ 73/*
67/* a value TUSEC for TICK_USEC (can be set bij adjtimex) */ 74 * TICK_USEC_TO_NSEC is the time between ticks in nsec assuming SHIFTED_HZ and
68#define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV (TUSEC * USER_HZ * 1000, ACTHZ, 8)) 75 * a value TUSEC for TICK_USEC (can be set bij adjtimex)
76 */
77#define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV(TUSEC * USER_HZ * 1000, SHIFTED_HZ, 8))
69 78
70/* some arch's have a small-data section that can be accessed register-relative 79/* some arch's have a small-data section that can be accessed register-relative
71 * but that can only take up to, say, 4-byte variables. jiffies being part of 80 * but that can only take up to, say, 4-byte variables. jiffies being part of