POK(kernelpart)
__udivdi3.c
Go to the documentation of this file.
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 
18 
19 unsigned long long __udivdi3 (unsigned long long num,
20  unsigned long long den)
21 {
22 #ifdef POK_NEEDS_DEBUG
23  unsigned long long quot, qbit;
24 
25  quot = 0;
26  qbit = 1;
27 
28  if (den == 0)
29  {
30  return 0;
31  }
32 
33  while ((long long) den >= 0)
34  {
35  den <<= 1;
36  qbit <<= 1;
37  }
38 
39  while (qbit)
40  {
41  if (den <= num)
42  {
43  num -= den;
44  quot += qbit;
45  }
46  den >>= 1;
47  qbit >>= 1;
48  }
49 
50  return quot;
51 #else
52  (void) num;
53  (void) den;
54  return 0;
55 #endif
56 }
57