lkml.org 
[lkml]   [2003]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: div64.h:do_div() bug
On Mon, Sep 29, 2003 at 03:25:19PM +0200, Artur Klauser wrote:
> I've found that a bug in asm-arm/div64.h:do_div() is preventing correct
> conversion of timestamps in smbfs (and probably ntfs as well) from NT to
> Unix format. I'll post a patch that fixes the bug, but I think it is also
> present in other architectures - at least SPARC, SH, and CRIS look
> suspicious.
>
> If people with access to these architectures could run the following small
> test and let me know the outcome, I can fix it there too - thanks.

Call it "lack/lazyness of implementation"

Long ago it was used only in printk() debug printouts.
Now it is used all over the place. At least its users are aware of
it being slow, and not just using GCC's magic bultin codes.


> //-----------------------------------------------------------------------------
> #define __KERNEL__
> #include <asm/types.h> // get kernel definition of u64, u32
> #undef __KERNEL__
> #include <asm/div64.h> // get definition of do_div()
> #include <stdio.h>
>
> main () {
> union {
> u64 n64;
> u32 n32[2];
> } in, out;
>
> in.n32[0] = 1;
> in.n32[1] = 1;
> out = in;
>
> do_div(out.n64, 1);
>
> if (in.n64 != out.n64) {
> printf("FAILURE: asm/div64.h:do_div() is broken for 64-bit dividends\n");
> exit(1);
> } else {
> printf("Congratulations: asm/div64.h:do_div() handles 64-bit dividends\n");
> }
> return 0;
> }
-
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 13:48    [W:0.036 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site