lkml.org 
[lkml]   [2002]   [Dec]   [23]   [last100]   RSS Feed
Views: [more markup]   [less markup]   [headers]   [forward]  
 
Messages in this thread
Patch in this message
/
DateMon, 23 Dec 2002 16:24:38 +1100
FromStephen Rothwell <>
SubjectRe: [RESEND][PATCH] better compat_jiffies_to_clock_t
On Sun, 22 Dec 2002 21:14:07 -0800 (PST) Linus Torvalds <torvalds@transmeta.com> wrote:
> 
> I don't like using "long long" and divisions.
> 
> Since this code is currently only used for 64-bit targets, is there any
> reason to use "long long" at all, and not just use "long"? I can see a
> 64-bit target where "long long" would be 128 bits, and this would do the
> wrong thing.

I have no problem with just long.  David Mosberger suggested the
"long long" because it would always be the longest integer type
and therefore overflow less often (if at all).  But for now, you
are right.

New patch attached.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.52-32bit.base/include/linux/compat.h 2.5.52-32bit.clock/include/linux/compat.h
--- 2.5.52-32bit.base/include/linux/compat.h	2002-12-16 14:49:54.000000000 +1100
+++ 2.5.52-32bit.clock/include/linux/compat.h	2002-12-17 15:20:18.000000000 +1100
@@ -9,9 +9,11 @@
 #ifdef CONFIG_COMPAT
 
 #include <linux/stat.h>
+#include <linux/param.h>	/* for HZ */
 #include <asm/compat.h>
 
-#define compat_jiffies_to_clock_t(x)	((x) / (HZ / COMPAT_USER_HZ))
+#define compat_jiffies_to_clock_t(x)	\
+		(((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
 
 struct compat_utimbuf {
 	compat_time_t		actime;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 11:31    [W:0.538 / U:0.860 seconds]
©2003-2008 Jasper Spaans