lkml.org 
[lkml]   [2002]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Large Block device patch part 3/4

On Thu, 3 Oct 2002, Peter Chubb wrote:
>
> No, because the purpose of the cast is to avoid dividing a 64-bit
> quantity by an int. If you cast *after* the division, you still end
> up doing a 64-bit division.

Note that you could just use "do_div64()", which does a 64/32->64 division
(which is a _hell_ of a lot faster than a generic 64/64 division, and it's
a shame that gcc is too stupid to generate the right code directly - since
it's trivially visible to the compiler when somebody does a 64/32
division).

NOTE! do_div() has some rather strange but usefule calling conventions (it
will change the 64-bit argument to be the result of the division, and the
actual return value is the 32-bit modulus). Those are just because it ends
up being the most convenient way to efficiently return both values.

[ Explanation ]

The reason Linux doesn't include libgcc.a is that gcc is totally braindead
in some places, not because we don't like 64-bit divisions per se. Think
of it as a "uhhuh, if gcc needed libgcc.a, then gcc did something truly
horrible code generation" (and realize that quite often it is our fault,
it's not just gcc doing stupid things. 99% of the time we can just
simplify a division to a shift by hand, for example).

Linus

-
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:29    [W:0.045 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site