aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc/lib/libgcc/__udivmodsi4.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/parisc/lib/libgcc/__udivmodsi4.c')
-rw-r--r--arch/parisc/lib/libgcc/__udivmodsi4.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/arch/parisc/lib/libgcc/__udivmodsi4.c b/arch/parisc/lib/libgcc/__udivmodsi4.c
new file mode 100644
index 000000000000..2a2fc28b2026
--- /dev/null
+++ b/arch/parisc/lib/libgcc/__udivmodsi4.c
@@ -0,0 +1,31 @@
1#include "libgcc.h"
2
3u32 __udivmodsi4(u32 num, u32 den, u32 * rem_p)
4{
5 u32 quot = 0, qbit = 1;
6
7 if (den == 0) {
8 BUG();
9 }
10
11 /* Left-justify denominator and count shift */
12 while ((s32) den >= 0) {
13 den <<= 1;
14 qbit <<= 1;
15 }
16
17 while (qbit) {
18 if (den <= num) {
19 num -= den;
20 quot += qbit;
21 }
22 den >>= 1;
23 qbit >>= 1;
24 }
25
26 if (rem_p)
27 *rem_p = num;
28
29 return quot;
30}
31EXPORT_SYMBOL(__udivmodsi4);