blob: c556a5003aa989a1452c629273ff954281dbe58c [file] [log] [blame]
unsigned long udivmodsi4(unsigned long num, unsigned long den, int modwanted)
{
unsigned long bits = 1;
unsigned long ret = 0;
unsigned long tmpnum = num;
unsigned long tmpden = den;
while (tmpden < tmpnum && bits && !(tmpden & (1L<<31)))
{
tmpden <<=1;
bits <<=1;
}
while (bits)
{
if (tmpnum >= tmpden)
{
tmpnum -= tmpden;
ret |= bits;
}
bits >>=1;
tmpden >>=1;
}
if (modwanted) return tmpnum;
return ret;
}