1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-19 10:53:58 +00:00

Roll the LOG2 macro up again, I don't belive unrolling this for 64bits

make sense.

Sponsored by:	DARPA & NAI Labs.
This commit is contained in:
Poul-Henning Kamp 2002-05-14 08:01:34 +00:00
parent be1d673d24
commit 085559c4fc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=96567

View File

@ -30,37 +30,19 @@
#ifndef _SYS_BLIST_H_
#define _SYS_BLIST_H_
#define LOG2(v) (((u_daddr_t)(v) >= 0x80000000U) ? 31 : \
((u_daddr_t)(v) >= 0x40000000U) ? 30 : \
((u_daddr_t)(v) >= 0x20000000U) ? 29 : \
((u_daddr_t)(v) >= 0x10000000U) ? 28 : \
((u_daddr_t)(v) >= 0x08000000U) ? 27 : \
((u_daddr_t)(v) >= 0x04000000U) ? 26 : \
((u_daddr_t)(v) >= 0x02000000U) ? 25 : \
((u_daddr_t)(v) >= 0x01000000U) ? 24 : \
((u_daddr_t)(v) >= 0x00800000U) ? 23 : \
((u_daddr_t)(v) >= 0x00400000U) ? 22 : \
((u_daddr_t)(v) >= 0x00200000U) ? 21 : \
((u_daddr_t)(v) >= 0x00100000U) ? 20 : \
((u_daddr_t)(v) >= 0x00080000U) ? 19 : \
((u_daddr_t)(v) >= 0x00040000U) ? 18 : \
((u_daddr_t)(v) >= 0x00020000U) ? 17 : \
((u_daddr_t)(v) >= 0x00010000U) ? 16 : \
((u_daddr_t)(v) >= 0x00008000U) ? 15 : \
((u_daddr_t)(v) >= 0x00004000U) ? 14 : \
((u_daddr_t)(v) >= 0x00002000U) ? 13 : \
((u_daddr_t)(v) >= 0x00001000U) ? 12 : \
((u_daddr_t)(v) >= 0x00000800U) ? 11 : \
((u_daddr_t)(v) >= 0x00000400U) ? 10 : \
((u_daddr_t)(v) >= 0x00000200U) ? 9 : \
((u_daddr_t)(v) >= 0x00000100U) ? 8 : \
((u_daddr_t)(v) >= 0x00000080U) ? 7 : \
((u_daddr_t)(v) >= 0x00000040U) ? 6 : \
((u_daddr_t)(v) >= 0x00000020U) ? 5 : \
((u_daddr_t)(v) >= 0x00000010U) ? 4 : \
((u_daddr_t)(v) >= 0x00000008U) ? 3 : \
((u_daddr_t)(v) >= 0x00000004U) ? 2 : \
((u_daddr_t)(v) >= 0x00000002U) ? 1 : 0)
static __inline int
LOG2(u_daddr_t v)
{
int i = -1;
if (!v)
return(0);
while (v) {
i++;
v >>= 1;
}
return (i);
}
/*
* blmeta and bl_bitmap_t MUST be a power of 2 in size.