Rev 4065 | Rev 5056 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4065 | Rev 4103 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef _LINUX_JIFFIES_H |
1 | #ifndef _LINUX_JIFFIES_H |
2 | #define _LINUX_JIFFIES_H |
2 | #define _LINUX_JIFFIES_H |
Line 3... | Line 3... | ||
3 | 3 | ||
4 | //#include |
4 | #include |
5 | #include |
5 | #include |
6 | #include |
6 | #include |
7 | //#include |
7 | #include |
8 | //#include |
8 | //#include |
Line 9... | Line 9... | ||
9 | //#include |
9 | //#include |
Line 41... | Line 41... | ||
41 | # define SHIFT_HZ 13 |
41 | # define SHIFT_HZ 13 |
42 | #else |
42 | #else |
43 | # error Invalid value of HZ. |
43 | # error Invalid value of HZ. |
44 | #endif |
44 | #endif |
Line 45... | Line -... | ||
45 | - | ||
46 | /* LATCH is used in the interval timer and ftape setup. */ |
- | |
47 | #define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ |
- | |
48 | 45 | ||
49 | /* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can |
46 | /* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can |
50 | * improve accuracy by shifting LSH bits, hence calculating: |
47 | * improve accuracy by shifting LSH bits, hence calculating: |
51 | * (NOM << LSH) / DEN |
48 | * (NOM << LSH) / DEN |
52 | * This however means trouble for large NOM, because (NOM << LSH) may no |
49 | * This however means trouble for large NOM, because (NOM << LSH) may no |
Line 56... | Line 53... | ||
56 | * - (NOM % DEN) fits in (32 - LSH) bits. |
53 | * - (NOM % DEN) fits in (32 - LSH) bits. |
57 | */ |
54 | */ |
58 | #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ |
55 | #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ |
59 | + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN)) |
56 | + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN)) |
Line 60... | Line 57... | ||
60 | 57 | ||
61 | /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ |
58 | /* LATCH is used in the interval timer and ftape setup. */ |
- | 59 | #define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ |
|
- | 60 | ||
Line 62... | Line 61... | ||
62 | #define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) |
61 | extern int register_refined_jiffies(long clock_tick_rate); |
63 | 62 | ||
Line 64... | Line 63... | ||
64 | /* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */ |
63 | /* TICK_NSEC is the time between ticks in nsec assuming SHIFTED_HZ */ |
65 | #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8)) |
64 | #define TICK_NSEC ((NSEC_PER_SEC+HZ/2)/HZ) |
Line 66... | Line 65... | ||
66 | 65 | ||
- | 66 | /* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */ |
|
67 | /* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */ |
67 | #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) |
- | 68 | ||
68 | #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) |
69 | /* some arch's have a small-data section that can be accessed register-relative |
Line -... | Line 70... | ||
- | 70 | * but that can only take up to, say, 4-byte variables. jiffies being part of |
|
- | 71 | * an 8-byte variable may not be correctly accessed unless we force the issue |
|
- | 72 | */ |
|
- | 73 | #define __jiffy_data __attribute__((section(".data"))) |
|
69 | 74 | ||
70 | /* TICK_USEC_TO_NSEC is the time between ticks in nsec assuming real ACTHZ and */ |
75 | /* |
71 | /* a value TUSEC for TICK_USEC (can be set bij adjtimex) */ |
76 | * The 64-bit value is not atomic - you MUST NOT read it |
72 | #define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV (TUSEC * USER_HZ * 1000, ACTHZ, 8)) |
77 | * without sampling the sequence number in jiffies_lock. |
Line 90... | Line 95... | ||
90 | * wouldn't care). Gcc is currently neither. |
95 | * wouldn't care). Gcc is currently neither. |
91 | */ |
96 | */ |
92 | #define time_after(a,b) \ |
97 | #define time_after(a,b) \ |
93 | (typecheck(unsigned long, a) && \ |
98 | (typecheck(unsigned long, a) && \ |
94 | typecheck(unsigned long, b) && \ |
99 | typecheck(unsigned long, b) && \ |
95 | ((long)(b) - (long)(a) < 0)) |
100 | ((long)((b) - (a)) < 0)) |
96 | #define time_before(a,b) time_after(b,a) |
101 | #define time_before(a,b) time_after(b,a) |
Line 97... | Line 102... | ||
97 | 102 | ||
98 | #define time_after_eq(a,b) \ |
103 | #define time_after_eq(a,b) \ |
99 | (typecheck(unsigned long, a) && \ |
104 | (typecheck(unsigned long, a) && \ |
100 | typecheck(unsigned long, b) && \ |
105 | typecheck(unsigned long, b) && \ |
101 | ((long)(a) - (long)(b) >= 0)) |
106 | ((long)((a) - (b)) >= 0)) |
Line 102... | Line 107... | ||
102 | #define time_before_eq(a,b) time_after_eq(b,a) |
107 | #define time_before_eq(a,b) time_after_eq(b,a) |
103 | 108 | ||
104 | /* |
109 | /* |
Line 119... | Line 124... | ||
119 | * These must be used when utilizing jiffies_64 (i.e. return value of |
124 | * These must be used when utilizing jiffies_64 (i.e. return value of |
120 | * get_jiffies_64() */ |
125 | * get_jiffies_64() */ |
121 | #define time_after64(a,b) \ |
126 | #define time_after64(a,b) \ |
122 | (typecheck(__u64, a) && \ |
127 | (typecheck(__u64, a) && \ |
123 | typecheck(__u64, b) && \ |
128 | typecheck(__u64, b) && \ |
124 | ((__s64)(b) - (__s64)(a) < 0)) |
129 | ((__s64)((b) - (a)) < 0)) |
125 | #define time_before64(a,b) time_after64(b,a) |
130 | #define time_before64(a,b) time_after64(b,a) |
Line 126... | Line 131... | ||
126 | 131 | ||
127 | #define time_after_eq64(a,b) \ |
132 | #define time_after_eq64(a,b) \ |
128 | (typecheck(__u64, a) && \ |
133 | (typecheck(__u64, a) && \ |
129 | typecheck(__u64, b) && \ |
134 | typecheck(__u64, b) && \ |
130 | ((__s64)(a) - (__s64)(b) >= 0)) |
135 | ((__s64)((a) - (b)) >= 0)) |
Line 131... | Line 136... | ||
131 | #define time_before_eq64(a,b) time_after_eq64(b,a) |
136 | #define time_before_eq64(a,b) time_after_eq64(b,a) |
132 | 137 | ||
133 | #define time_in_range64(a, b, c) \ |
138 | #define time_in_range64(a, b, c) \ |