75273d0832
* config/mn10200/udivmod.c, config/mn10200/divmod.c, config/mn10200/udivmodsi4.c: Moved from here. * config/udivmod.c, config/divmod.c, config/udivmodsi4.c: To here. * config/mn10200/t-mn10200 (LIB2FUNCS_EXTRA): Use the generic C division functions. * config/m68hc11/t-m68hc11-gas (LIB2FUNCS_EXTRA): Likewise. From-SVN: r37868
25 lines
384 B
C
25 lines
384 B
C
unsigned long
|
|
udivmodsi4(unsigned long num, unsigned long den, int modwanted)
|
|
{
|
|
unsigned long bit = 1;
|
|
unsigned long res = 0;
|
|
|
|
while (den < num && bit && !(den & (1L<<31)))
|
|
{
|
|
den <<=1;
|
|
bit <<=1;
|
|
}
|
|
while (bit)
|
|
{
|
|
if (num >= den)
|
|
{
|
|
num -= den;
|
|
res |= bit;
|
|
}
|
|
bit >>=1;
|
|
den >>=1;
|
|
}
|
|
if (modwanted) return num;
|
|
return res;
|
|
}
|