view gcc/config/udivmodsi4.c @ 32:59194914942b

add documents. CbC-INSTALL: howto build the gcc for various systems. CbC-implementation.ja: methods of implementation for CbC's statement.
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Tue, 08 Dec 2009 14:07:28 +0900
parents a06113de4d67
children 77e2b8dfacca
line wrap: on
line source

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;
}