|
53 | 53 | * bitmap_find_next_zero_area_off(buf, len, pos, n, mask) as above |
54 | 54 | * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n |
55 | 55 | * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n |
| 56 | + * bitmap_replace(dst, old, new, mask, nbits) *dst = (*old & ~(*mask)) | (*new & *mask) |
56 | 57 | * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src) |
57 | 58 | * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) |
58 | 59 | * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap |
@@ -140,6 +141,9 @@ extern void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, |
140 | 141 | const unsigned long *bitmap2, unsigned int nbits); |
141 | 142 | extern int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, |
142 | 143 | const unsigned long *bitmap2, unsigned int nbits); |
| 144 | +extern void __bitmap_replace(unsigned long *dst, |
| 145 | + const unsigned long *old, const unsigned long *new, |
| 146 | + const unsigned long *mask, unsigned int nbits); |
143 | 147 | extern int __bitmap_intersects(const unsigned long *bitmap1, |
144 | 148 | const unsigned long *bitmap2, unsigned int nbits); |
145 | 149 | extern int __bitmap_subset(const unsigned long *bitmap1, |
@@ -434,6 +438,18 @@ static inline void bitmap_shift_left(unsigned long *dst, const unsigned long *sr |
434 | 438 | __bitmap_shift_left(dst, src, shift, nbits); |
435 | 439 | } |
436 | 440 |
|
| 441 | +static inline void bitmap_replace(unsigned long *dst, |
| 442 | + const unsigned long *old, |
| 443 | + const unsigned long *new, |
| 444 | + const unsigned long *mask, |
| 445 | + unsigned int nbits) |
| 446 | +{ |
| 447 | + if (small_const_nbits(nbits)) |
| 448 | + *dst = (*old & ~(*mask)) | (*new & *mask); |
| 449 | + else |
| 450 | + __bitmap_replace(dst, old, new, mask, nbits); |
| 451 | +} |
| 452 | + |
437 | 453 | static inline int bitmap_parse(const char *buf, unsigned int buflen, |
438 | 454 | unsigned long *maskp, int nmaskbits) |
439 | 455 | { |
|
0 commit comments