summaryrefslogtreecommitdiffstats
path: root/include/linux/bitmap.h
diff options
context:
space:
mode:
authorRandy Dunlap <rdunlap@infradead.org>2017-10-16 19:32:51 -0400
committerJonathan Corbet <corbet@lwn.net>2017-10-19 15:01:40 -0400
commit7d7363e403ce959941f80684cc5f33e747afff17 (patch)
tree793fe05bf0426d400b07b3077b8d521a93ea96f4 /include/linux/bitmap.h
parent718d50ec782caad13e0cc78fa6a76ff2226f3dd3 (diff)
documentation: kernel-api: add more info on bitmap functions
There are some good comments about bitmap operations in lib/bitmap.c and include/linux/bitmap.h, so format them for document generation and pull them into core-api/kernel-api.rst. I converted the "tables" of functions from using tabs to using spaces so that they are more readable in the source file and in the generated output. Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'include/linux/bitmap.h')
-rw-r--r--include/linux/bitmap.h105
1 files changed, 57 insertions, 48 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 5c4178016b1e..d9974c7a0a61 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -21,65 +21,74 @@
21 * See lib/bitmap.c for more details. 21 * See lib/bitmap.c for more details.
22 */ 22 */
23 23
24/* 24/**
25 * DOC: bitmap overview
26 *
25 * The available bitmap operations and their rough meaning in the 27 * The available bitmap operations and their rough meaning in the
26 * case that the bitmap is a single unsigned long are thus: 28 * case that the bitmap is a single unsigned long are thus:
27 * 29 *
28 * Note that nbits should be always a compile time evaluable constant. 30 * Note that nbits should be always a compile time evaluable constant.
29 * Otherwise many inlines will generate horrible code. 31 * Otherwise many inlines will generate horrible code.
30 * 32 *
31 * bitmap_zero(dst, nbits) *dst = 0UL 33 * ::
32 * bitmap_fill(dst, nbits) *dst = ~0UL 34 *
33 * bitmap_copy(dst, src, nbits) *dst = *src 35 * bitmap_zero(dst, nbits) *dst = 0UL
34 * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 36 * bitmap_fill(dst, nbits) *dst = ~0UL
35 * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 37 * bitmap_copy(dst, src, nbits) *dst = *src
36 * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 38 * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2
37 * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2) 39 * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2
38 * bitmap_complement(dst, src, nbits) *dst = ~(*src) 40 * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2
39 * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? 41 * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2)
40 * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? 42 * bitmap_complement(dst, src, nbits) *dst = ~(*src)
41 * bitmap_subset(src1, src2, nbits) Is *src1 a subset of *src2? 43 * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal?
42 * bitmap_empty(src, nbits) Are all bits zero in *src? 44 * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap?
43 * bitmap_full(src, nbits) Are all bits set in *src? 45 * bitmap_subset(src1, src2, nbits) Is *src1 a subset of *src2?
44 * bitmap_weight(src, nbits) Hamming Weight: number set bits 46 * bitmap_empty(src, nbits) Are all bits zero in *src?
45 * bitmap_set(dst, pos, nbits) Set specified bit area 47 * bitmap_full(src, nbits) Are all bits set in *src?
46 * bitmap_clear(dst, pos, nbits) Clear specified bit area 48 * bitmap_weight(src, nbits) Hamming Weight: number set bits
47 * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area 49 * bitmap_set(dst, pos, nbits) Set specified bit area
48 * bitmap_find_next_zero_area_off(buf, len, pos, n, mask) as above 50 * bitmap_clear(dst, pos, nbits) Clear specified bit area
49 * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n 51 * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area
50 * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n 52 * bitmap_find_next_zero_area_off(buf, len, pos, n, mask) as above
51 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src) 53 * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n
52 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) 54 * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n
53 * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap 55 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src)
54 * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz 56 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit)
55 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf 57 * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap
56 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf 58 * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz
57 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf 59 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf
58 * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf 60 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
59 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region 61 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf
60 * bitmap_release_region(bitmap, pos, order) Free specified bit region 62 * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf
61 * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region 63 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region
62 * bitmap_from_u32array(dst, nbits, buf, nwords) *dst = *buf (nwords 32b words) 64 * bitmap_release_region(bitmap, pos, order) Free specified bit region
63 * bitmap_to_u32array(buf, nwords, src, nbits) *buf = *dst (nwords 32b words) 65 * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
66 * bitmap_from_u32array(dst, nbits, buf, nwords) *dst = *buf (nwords 32b words)
67 * bitmap_to_u32array(buf, nwords, src, nbits) *buf = *dst (nwords 32b words)
68 *
64 */ 69 */
65 70
66/* 71/**
67 * Also the following operations in asm/bitops.h apply to bitmaps. 72 * DOC: bitmap bitops
73 *
74 * Also the following operations in asm/bitops.h apply to bitmaps.::
75 *
76 * set_bit(bit, addr) *addr |= bit
77 * clear_bit(bit, addr) *addr &= ~bit
78 * change_bit(bit, addr) *addr ^= bit
79 * test_bit(bit, addr) Is bit set in *addr?
80 * test_and_set_bit(bit, addr) Set bit and return old value
81 * test_and_clear_bit(bit, addr) Clear bit and return old value
82 * test_and_change_bit(bit, addr) Change bit and return old value
83 * find_first_zero_bit(addr, nbits) Position first zero bit in *addr
84 * find_first_bit(addr, nbits) Position first set bit in *addr
85 * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit
86 * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit
68 * 87 *
69 * set_bit(bit, addr) *addr |= bit
70 * clear_bit(bit, addr) *addr &= ~bit
71 * change_bit(bit, addr) *addr ^= bit
72 * test_bit(bit, addr) Is bit set in *addr?
73 * test_and_set_bit(bit, addr) Set bit and return old value
74 * test_and_clear_bit(bit, addr) Clear bit and return old value
75 * test_and_change_bit(bit, addr) Change bit and return old value
76 * find_first_zero_bit(addr, nbits) Position first zero bit in *addr
77 * find_first_bit(addr, nbits) Position first set bit in *addr
78 * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit
79 * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit
80 */ 88 */
81 89
82/* 90/**
91 * DOC: declare bitmap
83 * The DECLARE_BITMAP(name,bits) macro, in linux/types.h, can be used 92 * The DECLARE_BITMAP(name,bits) macro, in linux/types.h, can be used
84 * to declare an array named 'name' of just enough unsigned longs to 93 * to declare an array named 'name' of just enough unsigned longs to
85 * contain all bit positions from 0 to 'bits' - 1. 94 * contain all bit positions from 0 to 'bits' - 1.