Messages in this thread | | | Date | Fri, 4 Aug 2000 16:55:20 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: 64 bit divide/mod in 2.4.0-test5 |
| |
On Sat, 5 Aug 2000, Andrew Morton wrote: > Linus Torvalds wrote: > > > > There's some special-case code in <asm/div64.h>, which is used mainly > > for printk(), but can be used for other stuff too: > > Does this duplicate arch/i386/kernel/smpboot.c:div64()?
Looks that way.
The "smpboot.c" version is so complicated that I don't want to look what it does, but the comments certainly seem to imply that smpboot.c should just do an #include <asm/div64.h> and be done with it..
The do_div() interface is not exactly pretty, but it was designed for performance and printk() in mind. In particular, it was designed so that it would return _both_ the remainder and the quotient, as printk() needs both (the remainder for the actual number, and the quotient for the next time through the loop).
Also "do_div()" only does unsigned division, which is what most people want anyway.
So it looks like the smpboot div64() could be re-written as
#include <asm/div64.h>
static unsigned long long div64 (unsigned long long a, unsigned long b0) { do_div(a, b0); return a; }
but anybody that is nervous about it should probably test that it gives the same results.
Linus
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |