2002-05-09 Hassan Aurag <aurag@cae.com>
[official-gcc.git] / gcc / config / udivmodsi4.c
blob83c2340c2f8b4f3dd74b263a81278d9dc4c226bc
1 unsigned long
2 udivmodsi4(unsigned long num, unsigned long den, int modwanted)
4 unsigned long bit = 1;
5 unsigned long res = 0;
7 while (den < num && bit && !(den & (1L<<31)))
9 den <<=1;
10 bit <<=1;
12 while (bit)
14 if (num >= den)
16 num -= den;
17 res |= bit;
19 bit >>=1;
20 den >>=1;
22 if (modwanted) return num;
23 return res;