aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/bitops_64.h
diff options
context:
space:
mode:
authorAlexander van Heukelum <heukelum@mailshack.com>2008-03-15 08:04:42 -0400
committerIngo Molnar <mingo@elte.hu>2008-04-26 13:21:16 -0400
commit12d9c8420b9daa1da3d9e090640fb24bcd0deba2 (patch)
tree60affb5bdc5b857dfb3969234659caedbf2ff02a /include/asm-x86/bitops_64.h
parent64970b68d2b3ed32b964b0b30b1b98518fde388e (diff)
x86: merge the simple bitops and move them to bitops.h
Some of those can be written in such a way that the same inline assembly can be used to generate both 32 bit and 64 bit code. For ffs and fls, x86_64 unconditionally used the cmov instruction and i386 unconditionally used a conditional branch over a mov instruction. In the current patch I chose to select the version based on the availability of the cmov instruction instead. A small detail here is that x86_64 did not previously set CONFIG_X86_CMOV=y. Improved comments for ffs, ffz, fls and variations. Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86/bitops_64.h')
-rw-r--r--include/asm-x86/bitops_64.h76
1 files changed, 0 insertions, 76 deletions
diff --git a/include/asm-x86/bitops_64.h b/include/asm-x86/bitops_64.h
index 7118ef2cc4ec..a5fbe7a02a3f 100644
--- a/include/asm-x86/bitops_64.h
+++ b/include/asm-x86/bitops_64.h
@@ -35,71 +35,11 @@ static inline void set_bit_string(unsigned long *bitmap, unsigned long i,
35 } 35 }
36} 36}
37 37
38/**
39 * ffz - find first zero in word.
40 * @word: The word to search
41 *
42 * Undefined if no zero exists, so code should check against ~0UL first.
43 */
44static inline unsigned long ffz(unsigned long word)
45{
46 __asm__("bsfq %1,%0"
47 :"=r" (word)
48 :"r" (~word));
49 return word;
50}
51
52/**
53 * __ffs - find first bit in word.
54 * @word: The word to search
55 *
56 * Undefined if no bit exists, so code should check against 0 first.
57 */
58static inline unsigned long __ffs(unsigned long word)
59{
60 __asm__("bsfq %1,%0"
61 :"=r" (word)
62 :"rm" (word));
63 return word;
64}
65
66/*
67 * __fls: find last bit set.
68 * @word: The word to search
69 *
70 * Undefined if no zero exists, so code should check against ~0UL first.
71 */
72static inline unsigned long __fls(unsigned long word)
73{
74 __asm__("bsrq %1,%0"
75 :"=r" (word)
76 :"rm" (word));
77 return word;
78}
79
80#ifdef __KERNEL__ 38#ifdef __KERNEL__
81 39
82#include <asm-generic/bitops/sched.h> 40#include <asm-generic/bitops/sched.h>
83 41
84/** 42/**
85 * ffs - find first bit set
86 * @x: the word to search
87 *
88 * This is defined the same way as
89 * the libc and compiler builtin ffs routines, therefore
90 * differs in spirit from the above ffz (man ffs).
91 */
92static inline int ffs(int x)
93{
94 int r;
95
96 __asm__("bsfl %1,%0\n\t"
97 "cmovzl %2,%0"
98 : "=r" (r) : "rm" (x), "r" (-1));
99 return r+1;
100}
101
102/**
103 * fls64 - find last bit set in 64 bit word 43 * fls64 - find last bit set in 64 bit word
104 * @x: the word to search 44 * @x: the word to search
105 * 45 *
@@ -112,22 +52,6 @@ static inline int fls64(__u64 x)
112 return __fls(x) + 1; 52 return __fls(x) + 1;
113} 53}
114 54
115/**
116 * fls - find last bit set
117 * @x: the word to search
118 *
119 * This is defined the same way as ffs.
120 */
121static inline int fls(int x)
122{
123 int r;
124
125 __asm__("bsrl %1,%0\n\t"
126 "cmovzl %2,%0"
127 : "=&r" (r) : "rm" (x), "rm" (-1));
128 return r+1;
129}
130
131#define ARCH_HAS_FAST_MULTIPLIER 1 55#define ARCH_HAS_FAST_MULTIPLIER 1
132 56
133#include <asm-generic/bitops/hweight.h> 57#include <asm-generic/bitops/hweight.h>