diff options
author | Doug Moore <dougm@FreeBSD.org> | 2019-05-10 19:55:29 +0000 |
---|---|---|
committer | Doug Moore <dougm@FreeBSD.org> | 2019-05-10 19:55:29 +0000 |
commit | 09b380a1ff90d69b28ce8c738fbd0e87eb9cc521 (patch) | |
tree | 3b2808c4d81b1cd0cedd3cc0d5aa269ffd4bd47e /sys | |
parent | f04019c3c6afdd9c61844382d451f341ff0e359a (diff) | |
download | src-09b380a1ff90d69b28ce8c738fbd0e87eb9cc521.tar.gz src-09b380a1ff90d69b28ce8c738fbd0e87eb9cc521.zip |
Replace the expression "-mask & ~mask" with a function call that does
the same thing, but is commented so that it might be better
understood.
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D20231
Notes
Notes:
svn path=/head/; revision=347464
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_blist.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/kern/subr_blist.c b/sys/kern/subr_blist.c index 8fe47cfa187d..e19d53b50133 100644 --- a/sys/kern/subr_blist.c +++ b/sys/kern/subr_blist.c @@ -643,6 +643,19 @@ blst_next_leaf_alloc(blmeta_t *scan, daddr_t blk, int count) } /* + * Given a bitmask, flip all the bits from the least-significant 1-bit to the + * most significant bit. If the result is non-zero, then the least-significant + * 1-bit of the result is in the same position as the least-signification 0-bit + * in mask that is followed by a 1-bit. + */ +static inline u_daddr_t +flip_hibits(u_daddr_t mask) +{ + + return (-mask & ~mask); +} + +/* * BLST_LEAF_ALLOC() - allocate at a leaf in the radix tree (a bitmap). * * This function is the core of the allocator. Its execution time is @@ -659,7 +672,7 @@ blst_leaf_alloc(blmeta_t *scan, daddr_t blk, int count) count1 = count - 1; num_shifts = fls(count1); mask = scan->bm_bitmap; - while ((-mask & ~mask) != 0 && num_shifts > 0) { + while (flip_hibits(mask) != 0 && num_shifts > 0) { /* * If bit i is set in mask, then bits in [i, i+range1] are set * in scan->bm_bitmap. The value of range1 is equal to count1 |