aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-cris/arch-v32/bitops.h
diff options
context:
space:
mode:
authorMikael Starvik <mikael.starvik@axis.com>2005-07-27 14:44:44 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-27 19:26:01 -0400
commit51533b615e605d86154ec1b4e585c8ca1b0b15b7 (patch)
tree4a6d7d8494d2017632d83624fb71b36031e0e7e5 /include/asm-cris/arch-v32/bitops.h
parent5d01e6ce785884a5db5792cd2e5bb36fa82fe23c (diff)
[PATCH] CRIS update: new subarchitecture v32
New CRIS sub architecture named v32. From: Dave Jones <davej@redhat.com> Fix swapped kmalloc args Signed-off-by: Mikael Starvik <starvik@axis.com> Signed-off-by: Dave Jones <davej@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-cris/arch-v32/bitops.h')
-rw-r--r--include/asm-cris/arch-v32/bitops.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/include/asm-cris/arch-v32/bitops.h b/include/asm-cris/arch-v32/bitops.h
new file mode 100644
index 000000000000..e40a58d3b862
--- /dev/null
+++ b/include/asm-cris/arch-v32/bitops.h
@@ -0,0 +1,64 @@
1#ifndef _ASM_CRIS_ARCH_BITOPS_H
2#define _ASM_CRIS_ARCH_BITOPS_H
3
4/*
5 * Helper functions for the core of the ff[sz] functions. They compute the
6 * number of leading zeroes of a bits-in-byte, byte-in-word and
7 * word-in-dword-swapped number. They differ in that the first function also
8 * inverts all bits in the input.
9 */
10
11extern inline unsigned long
12cris_swapnwbrlz(unsigned long w)
13{
14 unsigned long res;
15
16 __asm__ __volatile__ ("swapnwbr %0\n\t"
17 "lz %0,%0"
18 : "=r" (res) : "0" (w));
19
20 return res;
21}
22
23extern inline unsigned long
24cris_swapwbrlz(unsigned long w)
25{
26 unsigned long res;
27
28 __asm__ __volatile__ ("swapwbr %0\n\t"
29 "lz %0,%0"
30 : "=r" (res) : "0" (w));
31
32 return res;
33}
34
35/*
36 * Find First Zero in word. Undefined if no zero exist, so the caller should
37 * check against ~0 first.
38 */
39extern inline unsigned long
40ffz(unsigned long w)
41{
42 return cris_swapnwbrlz(w);
43}
44
45/*
46 * Find First Set bit in word. Undefined if no 1 exist, so the caller
47 * should check against 0 first.
48 */
49extern inline unsigned long
50__ffs(unsigned long w)
51{
52 return cris_swapnwbrlz(~w);
53}
54
55/*
56 * Find First Bit that is set.
57 */
58extern inline unsigned long
59kernel_ffs(unsigned long w)
60{
61 return w ? cris_swapwbrlz (w) + 1 : 0;
62}
63
64#endif /* _ASM_CRIS_ARCH_BITOPS_H */