From 3ffab58232a24c121b021f624c13ee9b0dd3d1c5 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sat, 28 May 2005 19:02:24 +0000 Subject: [PATCH] added jiffies_to_msecs() and msleep_interruptible() to compatibility headers --- include/linux/delay.h | 24 ++++++++++++++++++++++++ include/linux/time.h | 18 +++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 include/linux/delay.h diff --git a/include/linux/delay.h b/include/linux/delay.h new file mode 100644 index 00000000..4ef87686 --- /dev/null +++ b/include/linux/delay.h @@ -0,0 +1,24 @@ + +#ifndef __COMPAT_LINUX_DELAY_H +#define __COMPAT_LINUX_DELAY_H + +#include +#include + +#include_next + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) +static inline unsigned long msleep_interruptible(unsigned int msecs) +{ + unsigned long timeout = msecs_to_jiffies(msecs); + + while (timeout && !signal_pending(current)) { + set_current_state(TASK_INTERRUPTIBLE); + timeout = schedule_timeout(timeout); + } + return jiffies_to_msecs(timeout); +} +#endif + +#endif + diff --git a/include/linux/time.h b/include/linux/time.h index 306b80fb..48345ccf 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -7,14 +7,26 @@ #include_next #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + +static inline unsigned int jiffies_to_msecs(const unsigned long j) +{ +#if HZ <= 1000 && !(1000 % HZ) + return (1000 / HZ) * j; +#elif HZ > 1000 && !(HZ % 1000) + return (j + (HZ / 1000) - 1)/(HZ / 1000); +#else + return (j * 1000) / HZ; +#endif +} + static inline unsigned long msecs_to_jiffies(const unsigned int m) { #if HZ <= 1000 && !(1000 % HZ) - return (m + (1000 / HZ) - 1) / (1000 / HZ); + return (m + (1000 / HZ) - 1) / (1000 / HZ); #elif HZ > 1000 && !(HZ % 1000) - return m * (HZ / 1000); + return m * (HZ / 1000); #else - return (m * HZ + 999) / 1000; + return (m * HZ + 999) / 1000; #endif }; -- 2.26.2