diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-08-21 12:26:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-08-21 12:26:15 -0400 |
commit | f4b0373b26567cafd421d91101852ed7a34e9e94 (patch) | |
tree | 35607b1c1d28429bb275ca3472cd0065fbde2f14 /lib | |
parent | 83d349f35e1ae72268c5104dbf9ab2ae635425d4 (diff) |
Make bitmask 'and' operators return a result code
When 'and'ing two bitmasks (where 'andnot' is a variation on it), some
cases want to know whether the result is the empty set or not. In
particular, the TLB IPI sending code wants to do cpumask operations and
determine if there are any CPU's left in the final set.
So this just makes the bitmask (and cpumask) functions return a boolean
for whether the result has any bits set.
Cc: stable@kernel.org (2.6.30, needed by TLB shootdown fix)
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bitmap.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 35a1f7ff4149..702565821c99 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -179,14 +179,16 @@ void __bitmap_shift_left(unsigned long *dst, | |||
179 | } | 179 | } |
180 | EXPORT_SYMBOL(__bitmap_shift_left); | 180 | EXPORT_SYMBOL(__bitmap_shift_left); |
181 | 181 | ||
182 | void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, | 182 | int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, |
183 | const unsigned long *bitmap2, int bits) | 183 | const unsigned long *bitmap2, int bits) |
184 | { | 184 | { |
185 | int k; | 185 | int k; |
186 | int nr = BITS_TO_LONGS(bits); | 186 | int nr = BITS_TO_LONGS(bits); |
187 | unsigned long result = 0; | ||
187 | 188 | ||
188 | for (k = 0; k < nr; k++) | 189 | for (k = 0; k < nr; k++) |
189 | dst[k] = bitmap1[k] & bitmap2[k]; | 190 | result |= (dst[k] = bitmap1[k] & bitmap2[k]); |
191 | return result != 0; | ||
190 | } | 192 | } |
191 | EXPORT_SYMBOL(__bitmap_and); | 193 | EXPORT_SYMBOL(__bitmap_and); |
192 | 194 | ||
@@ -212,14 +214,16 @@ void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, | |||
212 | } | 214 | } |
213 | EXPORT_SYMBOL(__bitmap_xor); | 215 | EXPORT_SYMBOL(__bitmap_xor); |
214 | 216 | ||
215 | void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, | 217 | int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, |
216 | const unsigned long *bitmap2, int bits) | 218 | const unsigned long *bitmap2, int bits) |
217 | { | 219 | { |
218 | int k; | 220 | int k; |
219 | int nr = BITS_TO_LONGS(bits); | 221 | int nr = BITS_TO_LONGS(bits); |
222 | unsigned long result = 0; | ||
220 | 223 | ||
221 | for (k = 0; k < nr; k++) | 224 | for (k = 0; k < nr; k++) |
222 | dst[k] = bitmap1[k] & ~bitmap2[k]; | 225 | result |= (dst[k] = bitmap1[k] & ~bitmap2[k]); |
226 | return result != 0; | ||
223 | } | 227 | } |
224 | EXPORT_SYMBOL(__bitmap_andnot); | 228 | EXPORT_SYMBOL(__bitmap_andnot); |
225 | 229 | ||