diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-01-04 16:03:48 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-01-04 16:03:48 +0000 |
commit | 78c388aed2b7184182c08428db1de6c872d815f5 (patch) | |
tree | 4b2003b1b4ceb241a17faa995da8dd1004bb8e45 /include/linux/time.h | |
parent | eb7a5bf93aaa4be1d7c6181100ab7639e74d67f7 (diff) |
Merge with Linux 2.1.131 and more MIPS goodies.
(Did I mention that CVS is buggy ...)
Diffstat (limited to 'include/linux/time.h')
-rw-r--r-- | include/linux/time.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index d60d8c776..d14feaaad 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -13,17 +13,27 @@ struct timespec { #endif /* _STRUCT_TIMESPEC */ /* - * change timeval to jiffies, trying to avoid the + * Change timeval to jiffies, trying to avoid the * most obvious overflows.. + * + * And some not so obvious. + * + * Note that we don't want to return MAX_LONG, because + * for various timeout reasons we often end up having + * to wait "jiffies+1" in order to guarantee that we wait + * at _least_ "jiffies" - so "jiffies+1" had better still + * be positive. */ +#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) + static __inline__ unsigned long timespec_to_jiffies(struct timespec *value) { unsigned long sec = value->tv_sec; long nsec = value->tv_nsec; - if (sec > ((long)(~0UL >> 1) / HZ)) - return ~0UL >> 1; + if (sec >= (MAX_JIFFY_OFFSET / HZ)) + return MAX_JIFFY_OFFSET; nsec += 1000000000L / HZ - 1; nsec /= 1000000000L / HZ; return HZ * sec + nsec; |