Re: [PATCH] Large Block device patch part 3/4

From: Linus Torvalds (torvalds@transmeta.com)
Date: Thu Oct 03 2002 - 11:13:08 EST


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/



This archive was generated by hypermail 2b29 : Mon Oct 07 2002 - 22:00:40 EST