It does look a bit better. Takes into account the issue of TICK_NSEC being what it is.diff -Nru a/include/linux/times.h b/include/linux/times.h
--- a/include/linux/times.h Tue Apr 13 15:00:25 2004
+++ b/include/linux/times.h Tue Apr 13 15:00:25 2004
@@ -7,7 +7,12 @@
#include <asm/param.h>
#if (HZ % USER_HZ)==0
-# define jiffies_to_clock_t(x) ((x) / (HZ / USER_HZ))
+static inline long jiffies_to_clock_t(long x)
+{
+ u64 tmp = (u64)x * TICK_NSEC;
+ x = do_div(tmp, (NSEC_PER_SEC / USER_HZ));
+ return (long)tmp;
+}
#else
# define jiffies_to_clock_t(x) ((clock_t) jiffies_64_to_clock_t((u64) x))
#endif
Excuse me for barging in lately and innocently, but I find this patch
hard to comprehend:
- shouldn't a foo_to_clock_t() function return a clock?
- the x = seems superfluous
- the #if is not a shortcut anymore, so why keep it?
Shouldn't this patch be more like the following
(completely untested)?
Tim
diff -urp --exclude-from dontdiff linux-2.6.5/include/linux/times.h linux-2.6.5-jfix1/include/linux/times.h
--- linux-2.6.5/include/linux/times.h 2004-02-04 04:43:09.000000000 +0100
+++ linux-2.6.5-jfix1/include/linux/times.h 2004-04-14 13:48:57.000000000 +0200
@@ -6,11 +6,16 @@
#include <asm/types.h>
#include <asm/param.h>
-#if (HZ % USER_HZ)==0
-# define jiffies_to_clock_t(x) ((x) / (HZ / USER_HZ))
-#else
-# define jiffies_to_clock_t(x) ((clock_t) jiffies_64_to_clock_t((u64) x))
-#endif
+static inline clock_t jiffies_to_clock_t(long x)
+{
+#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
+ return x / (HZ / USER_HZ);
+#else
+ u64 tmp = (u64)x * TICK_NSEC;
+ do_div(tmp, (NSEC_PER_SEC / USER_HZ));
+ return (long)tmp;
+#endif
+}
static inline unsigned long clock_t_to_jiffies(unsigned long x)
{