Rev 5056 | Rev 6082 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5056 | Rev 5270 | ||
---|---|---|---|
Line 75... | Line 75... | ||
75 | /* |
75 | /* |
76 | * The 64-bit value is not atomic - you MUST NOT read it |
76 | * The 64-bit value is not atomic - you MUST NOT read it |
77 | * without sampling the sequence number in jiffies_lock. |
77 | * without sampling the sequence number in jiffies_lock. |
78 | * get_jiffies_64() will do this for you as appropriate. |
78 | * get_jiffies_64() will do this for you as appropriate. |
79 | */ |
79 | */ |
80 | extern u64 jiffies_64; |
80 | extern u64 __jiffy_data jiffies_64; |
81 | extern unsigned long volatile jiffies; |
81 | extern unsigned long volatile __jiffy_data jiffies; |
Line 82... | Line 82... | ||
82 | 82 | ||
83 | #if (BITS_PER_LONG < 64) |
83 | #if (BITS_PER_LONG < 64) |
84 | u64 get_jiffies_64(void); |
84 | u64 get_jiffies_64(void); |
85 | #else |
85 | #else |
Line 260... | Line 260... | ||
260 | #if !((((NSEC_PER_SEC << 2) / TICK_NSEC) << (SEC_JIFFIE_SC - 2)) & 0x80000000) |
260 | #if !((((NSEC_PER_SEC << 2) / TICK_NSEC) << (SEC_JIFFIE_SC - 2)) & 0x80000000) |
261 | #undef SEC_JIFFIE_SC |
261 | #undef SEC_JIFFIE_SC |
262 | #define SEC_JIFFIE_SC (32 - SHIFT_HZ) |
262 | #define SEC_JIFFIE_SC (32 - SHIFT_HZ) |
263 | #endif |
263 | #endif |
264 | #define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29) |
264 | #define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29) |
265 | #define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19) |
- | |
266 | #define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\ |
265 | #define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\ |
267 | TICK_NSEC -1) / (u64)TICK_NSEC)) |
266 | TICK_NSEC -1) / (u64)TICK_NSEC)) |
Line 268... | Line 267... | ||
268 | 267 | ||
269 | #define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\ |
268 | #define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\ |
270 | TICK_NSEC -1) / (u64)TICK_NSEC)) |
- | |
271 | #define USEC_CONVERSION \ |
- | |
272 | ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\ |
- | |
273 | TICK_NSEC -1) / (u64)TICK_NSEC)) |
- | |
274 | /* |
- | |
275 | * USEC_ROUND is used in the timeval to jiffie conversion. See there |
- | |
276 | * for more details. It is the scaled resolution rounding value. Note |
- | |
277 | * that it is a 64-bit value. Since, when it is applied, we are already |
- | |
278 | * in jiffies (albit scaled), it is nothing but the bits we will shift |
- | |
279 | * off. |
- | |
280 | */ |
- | |
281 | #define USEC_ROUND (u64)(((u64)1 << USEC_JIFFIE_SC) - 1) |
269 | TICK_NSEC -1) / (u64)TICK_NSEC)) |
282 | /* |
270 | /* |
283 | * The maximum jiffie value is (MAX_INT >> 1). Here we translate that |
271 | * The maximum jiffie value is (MAX_INT >> 1). Here we translate that |
284 | * into seconds. The 64-bit case will overflow if we are not careful, |
272 | * into seconds. The 64-bit case will overflow if we are not careful, |
285 | * so use the messy SH_DIV macro to do it. Still all constants. |
273 | * so use the messy SH_DIV macro to do it. Still all constants. |
Line 323... | Line 311... | ||
323 | extern u64 jiffies_64_to_clock_t(u64 x); |
311 | extern u64 jiffies_64_to_clock_t(u64 x); |
324 | extern u64 nsec_to_clock_t(u64 x); |
312 | extern u64 nsec_to_clock_t(u64 x); |
325 | extern u64 nsecs_to_jiffies64(u64 n); |
313 | extern u64 nsecs_to_jiffies64(u64 n); |
326 | extern unsigned long nsecs_to_jiffies(u64 n); |
314 | extern unsigned long nsecs_to_jiffies(u64 n); |
Line 327... | Line -... | ||
327 | - | ||
328 | - | ||
329 | static unsigned long round_jiffies_common(unsigned long j, bool force_up) |
- | |
330 | { |
- | |
331 | int rem; |
- | |
332 | unsigned long original = j; |
- | |
333 | - | ||
334 | rem = j % HZ; |
- | |
335 | - | ||
336 | /* |
- | |
337 | * If the target jiffie is just after a whole second (which can happen |
- | |
338 | * due to delays of the timer irq, long irq off times etc etc) then |
- | |
339 | * we should round down to the whole second, not up. Use 1/4th second |
- | |
340 | * as cutoff for this rounding as an extreme upper bound for this. |
- | |
341 | * But never round down if @force_up is set. |
- | |
342 | */ |
- | |
343 | if (rem < HZ/4 && !force_up) /* round down */ |
- | |
344 | j = j - rem; |
- | |
345 | else /* round up */ |
- | |
346 | j = j - rem + HZ; |
- | |
347 | - | ||
348 | if (j <= GetTimerTicks()) /* rounding ate our timeout entirely; */ |
- | |
349 | return original; |
- | |
350 | return j; |
- | |
351 | } |
- | |
352 | - | ||
353 | - | ||
354 | - | ||
355 | unsigned long round_jiffies_up_relative(unsigned long j); |
- | |
356 | 315 | ||
Line 357... | Line 316... | ||
357 | #define TIMESTAMP_SIZE 30 |
316 | #define TIMESTAMP_SIZE 30 |