All of lore.kernel.org
 help / color / mirror / Atom feed
* [parisc-linux] teaching the kernel to do division
@ 2003-10-23  7:21 Randolph Chung
  2003-10-23 23:39 ` [parisc-linux] " Randolph Chung
  0 siblings, 1 reply; 5+ messages in thread
From: Randolph Chung @ 2003-10-23  7:21 UTC (permalink / raw)
  To: parisc-linux

I was investigating why nanosleep() doesn't return the correct remaining
time with a 2.6 kernel... turns out the kernel doesn't seem to know 
how to do division properly :-(

kernel/posix-timers.c has:

                tsave->tv_sec = div_long_long_rem(left,
                                                  NSEC_PER_SEC,
                                                  &tsave->tv_nsec);

which eventually calls __div64_32() in lib/div64.c

if you test that function, you see that it does weird things. For
example, it tells me that:

28999591392 / 1000000000 = 3, remainder = 229787616

<sigh>

does anyone want to look into fixing it, and/or writing an optimized
version of that function for pa? :-) it needs to do basically this (but
be standalone)

uint32_t div64(uint64_t *n, uint32_t base)
{
        uint32_t rem;

        rem = *n % base;
        *n = *n / base;

        return rem;
}

thanks :)
randolph
-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-10-25 16:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-23  7:21 [parisc-linux] teaching the kernel to do division Randolph Chung
2003-10-23 23:39 ` [parisc-linux] " Randolph Chung
2003-10-25 11:13   ` Joel Soete
2003-10-25 15:42     ` Joel Soete
2003-10-25 16:07     ` Randolph Chung

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.