diff options
author | Xin LI <delphij@FreeBSD.org> | 2014-04-18 21:15:12 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2014-04-18 21:15:12 +0000 |
commit | 613074ec080d9eff833bc3670c003e16decdea0f (patch) | |
tree | f9b95868ce5b65d893f646a7e4cc05e9a66369cc /sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h | |
parent | 2bb082980b7571d27d900760edf77ce395600829 (diff) | |
parent | 745fef148911aa617e5c739cfc7b0685a105a052 (diff) | |
download | src-613074ec080d9eff833bc3670c003e16decdea0f.tar.gz src-613074ec080d9eff833bc3670c003e16decdea0f.zip |
MFV r264666:
4374 dn_free_ranges should use range_tree_t
illumos/illumos-gate@bf16b11e8deb633dd6c4296d46e92399d1582df4
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=264669
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h')
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h index 18f20908191f..0d98b263583b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h @@ -409,6 +409,38 @@ highbit(ulong_t i) return (h); } +/* + * Find highest one bit set. + * Returns bit number + 1 of highest bit that is set, otherwise returns 0. + */ +static __inline int +highbit64(uint64_t i) +{ + int h = 1; + + if (i == 0) + return (0); + if (i & 0xffffffff00000000ULL) { + h += 32; i >>= 32; + } + if (i & 0xffff0000) { + h += 16; i >>= 16; + } + if (i & 0xff00) { + h += 8; i >>= 8; + } + if (i & 0xf0) { + h += 4; i >>= 4; + } + if (i & 0xc) { + h += 2; i >>= 2; + } + if (i & 0x2) { + h += 1; + } + return (h); +} + #ifdef __cplusplus } #endif |