diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-m32r/div64.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-m32r/div64.h')
-rw-r--r-- | include/asm-m32r/div64.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/asm-m32r/div64.h b/include/asm-m32r/div64.h new file mode 100644 index 000000000000..417a51bd552d --- /dev/null +++ b/include/asm-m32r/div64.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef _ASM_M32R_DIV64 | ||
2 | #define _ASM_M32R_DIV64 | ||
3 | |||
4 | /* $Id$ */ | ||
5 | |||
6 | /* unsigned long long division. | ||
7 | * Input: | ||
8 | * unsigned long long n | ||
9 | * unsigned long base | ||
10 | * Output: | ||
11 | * n = n / base; | ||
12 | * return value = n % base; | ||
13 | */ | ||
14 | #define do_div(n, base) \ | ||
15 | ({ \ | ||
16 | unsigned long _res, _high, _mid, _low; \ | ||
17 | \ | ||
18 | _low = (n) & 0xffffffffUL; \ | ||
19 | _high = (n) >> 32; \ | ||
20 | if (_high) { \ | ||
21 | _mid = (_high % (unsigned long)(base)) << 16; \ | ||
22 | _high = _high / (unsigned long)(base); \ | ||
23 | _mid += _low >> 16; \ | ||
24 | _low &= 0x0000ffffUL; \ | ||
25 | _low += (_mid % (unsigned long)(base)) << 16; \ | ||
26 | _mid = _mid / (unsigned long)(base); \ | ||
27 | _res = _low % (unsigned long)(base); \ | ||
28 | _low = _low / (unsigned long)(base); \ | ||
29 | n = _low + ((long long)_mid << 16) + \ | ||
30 | ((long long)_high << 32); \ | ||
31 | } else { \ | ||
32 | _res = _low % (unsigned long)(base); \ | ||
33 | n = (_low / (unsigned long)(base)); \ | ||
34 | } \ | ||
35 | _res; \ | ||
36 | }) | ||
37 | |||
38 | #endif /* _ASM_M32R_DIV64 */ | ||