Rev 5056 | Rev 6082 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5056 | Rev 5270 | ||
---|---|---|---|
Line 130... | Line 130... | ||
130 | upper &= mask; |
130 | upper &= mask; |
131 | } |
131 | } |
132 | lower = src[off + k]; |
132 | lower = src[off + k]; |
133 | if (left && off + k == lim - 1) |
133 | if (left && off + k == lim - 1) |
134 | lower &= mask; |
134 | lower &= mask; |
- | 135 | dst[k] = lower >> rem; |
|
- | 136 | if (rem) |
|
135 | dst[k] = upper << (BITS_PER_LONG - rem) | lower >> rem; |
137 | dst[k] |= upper << (BITS_PER_LONG - rem); |
136 | if (left && k == lim - 1) |
138 | if (left && k == lim - 1) |
137 | dst[k] &= mask; |
139 | dst[k] &= mask; |
138 | } |
140 | } |
139 | if (off) |
141 | if (off) |
140 | memset(&dst[lim - off], 0, off*sizeof(unsigned long)); |
142 | memset(&dst[lim - off], 0, off*sizeof(unsigned long)); |
Line 171... | Line 173... | ||
171 | else |
173 | else |
172 | lower = 0; |
174 | lower = 0; |
173 | upper = src[k]; |
175 | upper = src[k]; |
174 | if (left && k == lim - 1) |
176 | if (left && k == lim - 1) |
175 | upper &= (1UL << left) - 1; |
177 | upper &= (1UL << left) - 1; |
- | 178 | dst[k + off] = upper << rem; |
|
- | 179 | if (rem) |
|
176 | dst[k + off] = lower >> (BITS_PER_LONG - rem) | upper << rem; |
180 | dst[k + off] |= lower >> (BITS_PER_LONG - rem); |
177 | if (left && k + off == lim - 1) |
181 | if (left && k + off == lim - 1) |
178 | dst[k + off] &= (1UL << left) - 1; |
182 | dst[k + off] &= (1UL << left) - 1; |
179 | } |
183 | } |
180 | if (off) |
184 | if (off) |
181 | memset(dst, 0, off*sizeof(unsigned long)); |
185 | memset(dst, 0, off*sizeof(unsigned long)); |
Line 321... | Line 325... | ||
321 | *p &= ~mask_to_clear; |
325 | *p &= ~mask_to_clear; |
322 | } |
326 | } |
323 | } |
327 | } |
324 | EXPORT_SYMBOL(bitmap_clear); |
328 | EXPORT_SYMBOL(bitmap_clear); |
Line 325... | Line 329... | ||
325 | 329 | ||
326 | /* |
330 | /** |
327 | * bitmap_find_next_zero_area - find a contiguous aligned zero area |
331 | * bitmap_find_next_zero_area_off - find a contiguous aligned zero area |
328 | * @map: The address to base the search on |
332 | * @map: The address to base the search on |
329 | * @size: The bitmap size in bits |
333 | * @size: The bitmap size in bits |
330 | * @start: The bitnumber to start searching at |
334 | * @start: The bitnumber to start searching at |
331 | * @nr: The number of zeroed bits we're looking for |
335 | * @nr: The number of zeroed bits we're looking for |
- | 336 | * @align_mask: Alignment mask for zero area |
|
332 | * @align_mask: Alignment mask for zero area |
337 | * @align_offset: Alignment offset for zero area. |
333 | * |
338 | * |
334 | * The @align_mask should be one less than a power of 2; the effect is that |
339 | * The @align_mask should be one less than a power of 2; the effect is that |
335 | * the bit offset of all zero areas this function finds is multiples of that |
340 | * the bit offset of all zero areas this function finds plus @align_offset |
336 | * power of 2. A @align_mask of 0 means no alignment is required. |
341 | * is multiple of that power of 2. |
337 | */ |
342 | */ |
338 | unsigned long bitmap_find_next_zero_area(unsigned long *map, |
343 | unsigned long bitmap_find_next_zero_area_off(unsigned long *map, |
339 | unsigned long size, |
344 | unsigned long size, |
340 | unsigned long start, |
345 | unsigned long start, |
341 | unsigned int nr, |
346 | unsigned int nr, |
- | 347 | unsigned long align_mask, |
|
342 | unsigned long align_mask) |
348 | unsigned long align_offset) |
343 | { |
349 | { |
344 | unsigned long index, end, i; |
350 | unsigned long index, end, i; |
345 | again: |
351 | again: |
Line 346... | Line 352... | ||
346 | index = find_next_zero_bit(map, size, start); |
352 | index = find_next_zero_bit(map, size, start); |
347 | 353 | ||
Line 348... | Line 354... | ||
348 | /* Align allocation */ |
354 | /* Align allocation */ |
349 | index = __ALIGN_MASK(index, align_mask); |
355 | index = __ALIGN_MASK(index + align_offset, align_mask) - align_offset; |
350 | 356 | ||
351 | end = index + nr; |
357 | end = index + nr; |
Line 356... | Line 362... | ||
356 | start = i + 1; |
362 | start = i + 1; |
357 | goto again; |
363 | goto again; |
358 | } |
364 | } |
359 | return index; |
365 | return index; |
360 | } |
366 | } |
361 | EXPORT_SYMBOL(bitmap_find_next_zero_area); |
367 | EXPORT_SYMBOL(bitmap_find_next_zero_area_off); |
Line 362... | Line 368... | ||
362 | 368 | ||
363 | /* |
369 | /* |
364 | * Bitmap printing & parsing functions: first version by Nadia Yvette Chambers, |
370 | * Bitmap printing & parsing functions: first version by Nadia Yvette Chambers, |
365 | * second version by Paul Jackson, third by Joe Korty. |
371 | * second version by Paul Jackson, third by Joe Korty. |
Line 597... | Line 603... | ||
597 | * (for the curious, that's 40 plus the first ten terms of the |
603 | * (for the curious, that's 40 plus the first ten terms of the |
598 | * Fibonacci sequence.) |
604 | * Fibonacci sequence.) |
599 | * |
605 | * |
600 | * Further lets say we use the following code, invoking |
606 | * Further lets say we use the following code, invoking |
601 | * bitmap_fold() then bitmap_onto, as suggested above to |
607 | * bitmap_fold() then bitmap_onto, as suggested above to |
602 | * avoid the possitility of an empty @dst result: |
608 | * avoid the possibility of an empty @dst result: |
603 | * |
609 | * |
604 | * unsigned long *tmp; // a temporary bitmap's bits |
610 | * unsigned long *tmp; // a temporary bitmap's bits |
605 | * |
611 | * |
606 | * bitmap_fold(tmp, orig, bitmap_weight(relmap, bits), bits); |
612 | * bitmap_fold(tmp, orig, bitmap_weight(relmap, bits), bits); |
607 | * bitmap_onto(dst, tmp, relmap, bits); |
613 | * bitmap_onto(dst, tmp, relmap, bits); |